当前位置: 首页>>代码示例>>C#>>正文


C# Engine.GetType方法代码示例

本文整理汇总了C#中Engine.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.GetType方法的具体用法?C# Engine.GetType怎么用?C# Engine.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine的用法示例。


在下文中一共展示了Engine.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnGet

 protected override object OnGet(Engine engine)
 {
     var items = Arguments.Get(engine);
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var typeArgument = engine.GetType(TypeArgumentProperty, TypeArgumentPath, TypeArgumentCodeTree);
     return TypeHelper.CreateCollection(items, type, typeArgument);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:7,代码来源:Collection.cs

示例2: OnGet

 protected override object OnGet(Engine engine)
 {
     engine.SetYieldFrame();
     Body.Execute(engine);
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var typeArgument = engine.GetType(TypeArgumentProperty, TypeArgumentPath, TypeArgumentCodeTree);
     var collection = TypeHelper.CreateCollection(engine.GetYieldedValues(), type, typeArgument);
     return collection;
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:9,代码来源:Iterator.cs

示例3: OnExecute

 protected override void OnExecute(Engine engine)
 {
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var value = engine.Get(ValueProperty, Path, CodeTree, type);
     bool foundMatch = false;
     bool executedStatement = false;
     foreach (var statement in Body)
     {
         if (statement is Case)
         {
             // Fell through to a new case group.
             if (executedStatement) return;
             var caseStatement = statement as Case;
             if (!foundMatch)
             {
                 var testValue = caseStatement.Get(engine);
                 if (engine.ShouldInterrupt) return;
                 foundMatch = (bool)engine.Operator(Op.Equals, value, testValue);
             }
         }
         else
         {
             // Found a match
             if (foundMatch)
             {
                 statement.Execute(engine);
                 executedStatement = true;
                 if (engine.ShouldInterrupt) return;
             }
         }
     }
     if (!executedStatement) Default.Execute(engine);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:33,代码来源:Switch.cs

示例4: OnGet

 protected override object OnGet(Engine engine)
 {
     var type = engine.GetType(TypeProperty, Path, CodeTree);
     if (TypeArguments.Count != 0)
         type = type.MakeGenericType(TypeArguments.Get(engine).Cast<Type>().ToArray());
     return TypeHelper.CreateInstance(type, Arguments.Get(engine));
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:7,代码来源:New.cs

示例5: OnGet

        protected override object OnGet(Engine engine)
        {
            var type = engine.GetType(TypeProperty, Path, CodeTree);
            if (type == null)
            {
                var pairs = Properties.Select(property => new NameValuePair(property.PropertyName, property.Get(engine)));
                return DynamicHelper.CreateObject(ref dynamicType, pairs.ToArray());
            }

            var target = Activator.CreateInstance(type);
            foreach (var property in Properties)
            {
                var value = property.Get(engine);
                var propertyType = PathHelper.GetPropertyType(engine, target, property.PropertyName);
                if (typeof(IList).IsAssignableFrom(propertyType) && property.Value is Collection)
                {
                    var collection = PathHelper.GetProperty(engine, target, property.PropertyName) as IList;
                    foreach (var item in value as IEnumerable) collection.Add(item);
                }
                else if (typeof(IDictionary).IsAssignableFrom(propertyType) && property.Value is Collection)
                {
                    var dictionary = PathHelper.GetProperty(engine, target, property.PropertyName) as IDictionary;
                    foreach (DictionaryEntry entry in value as IEnumerable) dictionary.Add(entry.Key, entry.Value);
                }
                else
                    PathHelper.SetProperty(engine, target, property.PropertyName, value);
            }
            return target;
        }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:29,代码来源:Object.cs

示例6: OnGet

 protected override object OnGet(Engine engine)
 {
     var type = engine.GetType(TypeName);
     if (TypeArguments == null || TypeArguments.Count == 0) return type;
     var typeArgs = TypeArguments.Select(arg => arg.Get(engine)).Cast<Type>().ToArray();
     return type.MakeGenericType(typeArgs);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:7,代码来源:TypeNode.cs

示例7: OnExecute

 protected override void OnExecute(Engine engine)
 {
     if (!ShouldExecute(engine)) return;
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var value = engine.Get(ValueProperty, Path, CodeTree, type);
     if (Merge)
         foreach (var item in value as IList) engine.YieldValue(TypeHelper.Convert(item, type));
     else
         engine.YieldValue(value);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:10,代码来源:Yield.cs

示例8: OnExecute

 protected override void OnExecute(Engine engine)
 {
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var value = engine.Get(ValueProperty, Path, CodeTree) as IEnumerable;
     var name = engine.GetVariable(Var, VarCodeTree);
     foreach (object item in value)
     {
         engine.DefineVariable(name, TypeHelper.Convert(item, type));
         Body.Execute(engine);
         engine.ClearShouldContinue();
         if (engine.ShouldInterrupt) break;
     }
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:13,代码来源:ForEach.cs

示例9: AccessItem

 private object AccessItem(bool isSet, Engine engine, object value)
 {
     var op = isSet ? Op.SetItem : Op.GetItem;
     var context = engine.GetContext(Path, CodeTree);
     if (Arguments.Count != 0)
     {
         var combinedArgs = new object[] { context }.Concat(Arguments.Get(engine));
         if (isSet) combinedArgs.Concat(new object[] { value });
         return engine.Operator(op, combinedArgs.ToArray());
     }
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     var index = engine.Get(IndexProperty, IndexPath, IndexCodeTree, type);
     if (!isSet) return engine.Operator(op, context, index);
     return engine.Operator(op, context, index, value);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:15,代码来源:ItemAccessor.cs

示例10: OnGet

 protected override object OnGet(Engine engine)
 {
     if (Var != null) return engine.GetVariable(engine.GetVariable(Var, VarCodeTree));
     var context = engine.GetContext(Path, CodeTree);
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     if (PropertyName != null)
         return PathHelper.GetProperty(engine, context, PropertyName);
     if (FieldName != null)
         return PathHelper.GetField(engine, context, FieldName);
     if (DependencyProperty != null)
         return PathHelper.GetDependencyProperty(engine, context as DependencyObject, DependencyProperty);
     if (StaticPropertyName != null)
         return PathHelper.GetStaticProperty(engine, type, StaticPropertyName);
     if (StaticFieldName != null)
         return PathHelper.GetStaticField(engine, type, StaticFieldName);
     if (Path != null)
         return context;
     return engine.Get(SourceProperty);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:19,代码来源:Get.cs

示例11: Main

        private static void Main(string[] args)
        {
            string sourceFo = null,
                   outputFilePath = null;
            foreach (var arg in args)
            {
                var key = arg.Substring(1, arg.IndexOf(":", StringComparison.InvariantCulture) - 1);
                var value = arg.Substring(key.Length + 2);
                switch (key)
                {
                    case "input":
                        sourceFo = File.ReadAllText(value);
                        break;
                    case "fo":
                        var fobytes = Convert.FromBase64String(value);
                        sourceFo = Encoding.Default.GetString(fobytes);
                        break;
                    case "output":
                        outputFilePath = value;
                        break;
                }
            }

            if (sourceFo == null)
            {
                return;
            }

            var e = new Engine();
            var runMethod = e.GetType().GetMethod("Run");
            var spdf = runMethod.Invoke(e, new object[] { sourceFo }) as sbyte[];

            if (spdf == null)
            {
                throw new Exception("Unexpected type returned from transform.");
            }

            var size = spdf.Length;
            var pdf = new byte[size];
            for (var i = 0; i < size; i++)
            {
                pdf[i] = (byte)spdf[i];
            }

            if (outputFilePath == null)
            {
                Console.WriteLine("--pdf start--");
                Console.WriteLine(Convert.ToBase64String(pdf));
                Console.WriteLine("--pdf end--");
            }
            else
            {
                try
                {
                    File.WriteAllBytes(outputFilePath, pdf);
                }
                catch
                {
                    Console.WriteLine("Error writing to file: " + outputFilePath);
                }
            }
        }
开发者ID:richardldavis,项目名称:AgileProjectDashboard,代码行数:62,代码来源:Program.cs

示例12: OnGet

 protected override object OnGet(Engine engine)
 {
     if (Quote) return engine.Quote(ValueProperty);
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     return engine.Get(ValueProperty, Path, CodeTree, type);
 }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:6,代码来源:Expr.cs

示例13: createAreaEffect

		public void createAreaEffect(Engine.AreaEffects.AreaEffect areaEffect)
		{
            IAreaEffectGUI gui = (IAreaEffectGUI)Activator.CreateInstance(Type.GetType("Assets.Scripts.GUI.AreaEffects." + areaEffect.GetType().Name + "GUI, Assembly-CSharp"));
            areaEffectGUIs.AddLast(gui);
            gui.createAreaEffect(areaEffect);
		}
开发者ID:btasdoven,项目名称:ScienceWars,代码行数:6,代码来源:GraphicsGame.cs

示例14: createMissile

		public void createMissile(Engine.Missiles.Missile missile)
		{
			IMissileGUI gui = (IMissileGUI)Activator.CreateInstance(Type.GetType("Assets.Scripts.GUI.Missiles." + missile.GetType().Name + "GUI, Assembly-CSharp"));
			missileGUIs.AddLast(gui);
			gui.createMissile(missile);
		}
开发者ID:btasdoven,项目名称:ScienceWars,代码行数:6,代码来源:GraphicsGame.cs

示例15: addMinionEffect

		public void addMinionEffect(Engine.Minions.Minion minion, Engine.Effects.MinionEffects.MinionEffect effect)
		{
            Type guiType = Type.GetType("Assets.Scripts.GUI.MinionEffects." + effect.GetType().Name + "GUI, Assembly-CSharp");
            if (guiType != null)
            {
                IMinionEffectGUI gui = (IMinionEffectGUI)Activator.CreateInstance(guiType);
                minionEffectGUIs.AddLast(gui);
                gui.createMinionEffect(minion, effect);
            }
		}
开发者ID:btasdoven,项目名称:ScienceWars,代码行数:10,代码来源:GraphicsGame.cs


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