• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CloneContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CloneContext的典型用法代码示例。如果您正苦于以下问题:C# CloneContext类的具体用法?C# CloneContext怎么用?C# CloneContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CloneContext类属于命名空间,在下文中一共展示了CloneContext类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: XenkoShaderMixer

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="moduleMixin">the final shader information</param>
        /// <param name="log">The log.</param>
        /// <param name="context">all the mixins in the context</param>
        /// <param name="compositionsPerVariable">The compositions per variable.</param>
        /// <param name="cloneContext">The clone context.</param>
        /// <exception cref="System.ArgumentNullException">
        /// moduleMixin
        /// or
        /// log
        /// or
        /// context
        /// </exception>
        public XenkoShaderMixer(ModuleMixin moduleMixin, LoggerResult log, Dictionary<string, ModuleMixin> context, CompositionDictionary compositionsPerVariable, CloneContext cloneContext = null)
        {
            if (moduleMixin == null)
                throw new ArgumentNullException("moduleMixin");

            if (log == null) 
                throw new ArgumentNullException("log");

            if (context == null)
                throw new ArgumentNullException("context");

            this.log = log;

            mixContext = context;
            mainModuleMixin = moduleMixin;
            defaultCloneContext = cloneContext;

            if (compositionsPerVariable != null)
                CompositionsPerVariable = compositionsPerVariable;
            else
                CompositionsPerVariable = new CompositionDictionary();

            var mixinsToAnalyze = new Stack<ModuleMixin>(CompositionsPerVariable.Values.SelectMany(x => x));
            mixinsToAnalyze.Push(mainModuleMixin);

            while (mixinsToAnalyze.Count > 0)
                AddDefaultCompositions(mixinsToAnalyze);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:43,代码来源:XenkoShaderMixer.cs


示例2: CloneTo

        protected override void CloneTo(CloneContext clonectx, Expression target)
        {
            base.CloneTo (clonectx, target);

            AQueryClause t = (AQueryClause) target;

            if (block != null)
                t.block = (QueryBlock) clonectx.LookupBlock (block);

            if (next != null)
                t.next = (AQueryClause) next.Clone (clonectx);
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:12,代码来源:linq.cs


示例3: CloneTo

		protected override void CloneTo (CloneContext clonectx, Expression target)
		{
			Join t = (Join) target;
			t.inner_selector = (QueryBlock) inner_selector.Clone (clonectx);
			t.outer_selector = (QueryBlock) outer_selector.Clone (clonectx);
			base.CloneTo (clonectx, t);
		}	
开发者ID:alisci01,项目名称:mono,代码行数:7,代码来源:linq.cs


示例4: BuildCompositionsDictionary

        /// <summary>
        /// create the context for each composition by cloning their dependencies
        /// </summary>
        /// <param name="shaderSource">the entry ShaderSource (root)</param>
        /// <param name="dictionary">the ouputed compositions</param>
        /// <param name="compilationContext">the compilation context</param>
        /// <param name="cloneContext">The clone context.</param>
        /// <returns>a list of all the needed mixins</returns>
        private static List<ModuleMixin> BuildCompositionsDictionary(ShaderSource shaderSource, CompositionDictionary dictionary, ShaderCompilationContext compilationContext, CloneContext cloneContext, LoggerResult log)
        {
            if (shaderSource is ShaderMixinSource)
            {
                var shaderMixinSource = shaderSource as ShaderMixinSource;

                var finalModule = compilationContext.GetModuleMixinFromShaderSource(shaderSource);

                //PerformanceLogger.Start(PerformanceStage.DeepClone);
                finalModule = finalModule.DeepClone(new CloneContext(cloneContext));
                //PerformanceLogger.Pause(PerformanceStage.DeepClone);

                foreach (var composition in shaderMixinSource.Compositions)
                {
                    //look for the key
                    var foundVars = finalModule.FindAllVariablesByName(composition.Key).Where(value => value.Variable.Qualifiers.Contains(ParadoxStorageQualifier.Compose)).ToList();

                    if (foundVars.Count > 1)
                    {
                        log.Error(ParadoxMessageCode.ErrorAmbiguousComposition, new SourceSpan(), composition.Key);
                    }
                    else if (foundVars.Count > 0)
                    {
                        Variable foundVar = foundVars[0].Variable;
                        var moduleMixins = BuildCompositionsDictionary(composition.Value, dictionary, compilationContext, cloneContext, log);
                        if (moduleMixins == null)
                            return null;

                        dictionary.Add(foundVar, moduleMixins);
                    }
                    else
                    {
                        // No matching variable was found
                        // TODO: log a message?
                    }
                }
                return new List<ModuleMixin> { finalModule };
            }


            if (shaderSource is ShaderClassSource)
            {
                var finalModule = compilationContext.GetModuleMixinFromShaderSource(shaderSource);

                //PerformanceLogger.Start(PerformanceStage.DeepClone);
                finalModule = finalModule.DeepClone(new CloneContext(cloneContext));
                //PerformanceLogger.Pause(PerformanceStage.DeepClone);

                return new List<ModuleMixin> { finalModule };
            }

            if (shaderSource is ShaderArraySource)
            {
                var shaderArraySource = shaderSource as ShaderArraySource;
                var compositionArray = new List<ModuleMixin>();
                foreach (var shader in shaderArraySource.Values)
                {
                    var mixin = BuildCompositionsDictionary(shader, dictionary, compilationContext, cloneContext, log);
                    if (mixin == null)
                        return null;
                    compositionArray.AddRange(mixin);
                }
                return compositionArray;
            }

            return null;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:75,代码来源:ShaderMixinParser.cs


示例5: Initialize

            public void Initialize(CloneContext previousCloneContext)
            {
                // Clone original context
                var cloneContext = new CloneContext();

                foreach (var keyValurPair in previousCloneContext)
                {
                    cloneContext.Add(keyValurPair.Key, keyValurPair.Value);
                }

                // Removes the method to clone
                cloneContext.Remove(Method);

                // Clone the old method with the clone context
                NewMethod = Method.DeepClone(cloneContext);

                var oldParameters = NewMethod.Parameters;
                NewMethod.Parameters = new List<Parameter>();
                int j = 0;
                for (int i = 0; i < oldParameters.Count; i++)
                {
                    var parameter = oldParameters[i];
                    var variableValue = (Variable)this.Method.Parameters[i].GetTag(ScopeValueKey);
                    if (variableValue != null)
                    {
                        this.NewMethod.Body.Insert(j, new DeclarationStatement(parameter));
                        j++;
                        parameter.InitialValue = new VariableReferenceExpression(variableValue.Name) { TypeInference = { Declaration = variableValue, TargetType = variableValue.Type } };
                    }
                    else
                        NewMethod.Parameters.Add(parameter);
                }

                // Create new method with new method name
                var methodNameBuild = new StringBuilder();
                methodNameBuild.Append(Method.Name);
                foreach (var variable in Variables)
                {
                    methodNameBuild.Append("_");
                    methodNameBuild.Append(variable.Name);
                }
                methodName = methodNameBuild.ToString();
                NewMethod.Name = methodName;
            }
开发者ID:ItayGal2,项目名称:paradox,代码行数:44,代码来源:SamplerMappingVisitor.cs


示例6: Clone

		public Arguments Clone (CloneContext ctx)
		{
			Arguments cloned = new Arguments (args.Count);
			foreach (Argument a in args)
				cloned.Add (a.Clone (ctx));

			return cloned;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:8,代码来源:argument.cs


示例7: CloneTo

		protected override void CloneTo (CloneContext clonectx, Expression t)
		{
			AsIn target = (AsIn) t;

			target.expr = expr.Clone (clonectx);
			target.objExpr = objExpr.Clone (clonectx);
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:ps-lang.cs


示例8: CloneInternal

 internal override Statement CloneInternal(CloneContext ctx)
 {
     IfStatement clone = new IfStatement();
     ctx.Map(this, clone);
     foreach (Expression e in Conditions)
         clone.Conditions.Add(e);
     foreach (Statement b in Branches)
         clone.Branches.Add(b.GetClone(ctx));
     return clone;
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:10,代码来源:Algorithms.cs


示例9: CloneTo

		protected override void CloneTo (CloneContext clonectx, Expression t)
		{
			Assign _target = (Assign) t;

			_target.target = target.Clone (clonectx);
			_target.source = source.Clone (clonectx);
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:assign.cs


示例10: ExportDwgToJpg

        public void ExportDwgToJpg(string destPath)
        {
            string sourcePath = String.Format("{0}{1}.dwg", DefaultDwgFolder, Control.ControlNo);
            Dictionary<string, string> dictDim = new Dictionary<string, string>();

            foreach (ControlDrawingDetail detail in ControlDrawingDetails)
            {
                if (dictDim.ContainsKey(detail.Dim.DimNo) == false)
                {
                    dictDim.Add(detail.Dim.DimNo, detail.DimValue);
                }
            }

            try
            {
                DxfModel readModel = DwgReader.Read(sourcePath);
                DxfModel writeModel = new DxfModel();
                CloneContext ct = new CloneContext(readModel, ReferenceResolutionType.CloneMissing);
                TransformConfig tc = new TransformConfig();
                Matrix4D translation = Transformation4D.Translation(250, 0, 0);

                ct.RenameClashingBlocks = true;

                for (int i = 0; i < readModel.Entities.Count; i++)
                {
                    DxfEntity block = readModel.Entities[i];

                    if (block.GetType() == typeof(DxfMText))
                    {
                        DxfMText di = (DxfMText)block;
                        if (dictDim.ContainsKey(di.SimplifiedText))
                        {
                            di.Text = dictDim[di.SimplifiedText];
                            di.Width = di.BoxWidth * 2;
                        }

                        writeModel.Entities.Add(di);
                    }
                    else if (block.GetType() == typeof(DxfText))
                    {
                        DxfText di = (DxfText)block;
                        if (dictDim.ContainsKey(di.SimplifiedText))
                        {
                            di.Text = dictDim[di.SimplifiedText];
                        }

                        writeModel.Entities.Add(di);
                    }
                    else
                    {
                        writeModel.Entities.Add(block);
                    }
                }

                ct.ResolveReferences();
                CADHelper.ExportToJpg(writeModel, destPath);
            }
            catch (Exception exc)
            {
                Tracing.Tracer.LogError(exc.Message);
                Logger.For(this).Error(exc.Message);
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:63,代码来源:ControlDrawing.cs


示例11: Parse

        /// <summary>
        /// Mixes shader parts to produces a single HLSL file shader.
        /// </summary>
        /// <param name="shaderMixinSource">The shader source.</param>
        /// <param name="macros">The shader perprocessor macros.</param>
        /// <param name="modifiedShaders">The list of modified shaders.</param>
        /// <returns>The combined shader in AST form.</returns>
        public ShaderMixinParsingResult Parse(ShaderMixinSource shaderMixinSource, Paradox.Shaders.ShaderMacro[] macros = null)
        {
            // Creates a parsing result
            HashSet<ModuleMixinInfo> mixinsToAnalyze;
            ShaderMixinParsingResult parsingResult;
            var context = ParseAndAnalyze(shaderMixinSource, macros, out parsingResult, out mixinsToAnalyze);

            // Return directly if there was any errors
            if (parsingResult.HasErrors)
                return parsingResult;

            // Update the clone context in case new instances of classes are created
            lock (hlslCloneContext)
            {
                HlslSemanticAnalysis.UpdateCloneContext(hlslCloneContext);
            }

            // only clone once the stage classes
            var mixCloneContext = new CloneContext(hlslCloneContext);
            foreach (var mixinInfo in mixinsToAnalyze)
            {
                foreach (var mixin in mixinInfo.Mixin.MinimalContext.Where(x => x.StageOnlyClass))
                {
                    mixin.DeepClone(mixCloneContext);
                }
            }

            // ----------------------------------------------------------
            // Perform Shader Mixer
            // ----------------------------------------------------------
            var externDict = new CompositionDictionary();
            var finalModuleList = BuildCompositionsDictionary(shaderMixinSource, externDict, context, mixCloneContext, parsingResult);
            //PerformanceLogger.Stop(PerformanceStage.DeepClone);

            if (parsingResult.HasErrors)
                return parsingResult;

            // look for stage compositions and add the links between variables and compositions when necessary
            var extraExternDict = new Dictionary<Variable, List<ModuleMixin>>();
            foreach (var item in externDict)
            {
                if (item.Key.Qualifiers.Contains(ParadoxStorageQualifier.Stage))
                    FullLinkStageCompositions(item.Key, item.Value, externDict, extraExternDict, parsingResult);
            }
            foreach (var item in extraExternDict)
                externDict.Add(item.Key, item.Value);

            var mixinDictionary = BuildMixinDictionary(finalModuleList);

            if (finalModuleList != null)
            {
                var finalModule = finalModuleList[0];
                //PerformanceLogger.Start(PerformanceStage.Mix);
                var mixer = new ParadoxShaderMixer(finalModule, parsingResult, mixinDictionary, externDict, new CloneContext(mixCloneContext));
                mixer.Mix();
                //PerformanceLogger.Stop(PerformanceStage.Mix);

                // Return directly if there was any errors
                if (parsingResult.HasErrors)
                    return parsingResult;

                var finalShader = mixer.GetMixedShader();

                // Simplifies the shader by removing dead code
                var simplifier = new ExpressionSimplifierVisitor();
                simplifier.Run(finalShader);

                parsingResult.Reflection = new EffectReflection();
                var pdxShaderLinker = new ShaderLinker(parsingResult);
                pdxShaderLinker.Run(finalShader);

                // Return directly if there was any errors
                if (parsingResult.HasErrors)
                    return parsingResult;

                // Find all entry points
                // TODO: make this configurable by CompileParameters
                foreach (var stage in new[] {ShaderStage.Compute, ShaderStage.Vertex, ShaderStage.Hull, ShaderStage.Domain, ShaderStage.Geometry, ShaderStage.Pixel})
                {
                    var entryPoint = finalShader.Declarations.OfType<MethodDefinition>().FirstOrDefault(f => f.Attributes.OfType<AttributeDeclaration>().Any(a => a.Name == "EntryPoint" && (string)a.Parameters[0].Value == stage.ToString()));

                    if (entryPoint == null)
                    {
                        continue;
                    }

                    parsingResult.EntryPoints[stage] = entryPoint.Name.Text;
                    
                    // When this is a compute shader, there is no need to scan other stages
                    if (stage == ShaderStage.Compute)
                        break;
                }

//.........这里部分代码省略.........
开发者ID:Powerino73,项目名称:paradox,代码行数:101,代码来源:ShaderMixinParser.cs


示例12: CloneTo

		protected override void CloneTo (CloneContext clonectx, Expression t)
		{
			CompletionMemberAccess target = (CompletionMemberAccess) t;

			if (targs != null)
				target.targs = targs.Clone ();

			target.expr = expr.Clone (clonectx);
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:9,代码来源:complete.cs


示例13: CloneTo

		protected override void CloneTo (CloneContext clonectx, Expression t)
		{
			NullCoalescingOperator target = (NullCoalescingOperator) t;

			target.left = left.Clone (clonectx);
			target.right = right.Clone (clonectx);
		}
开发者ID:saga,项目名称:mono,代码行数:7,代码来源:nullable.cs



注:本文中的CloneContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cloner类代码示例发布时间:2022-05-24
下一篇:
C# Clock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap