DisplayClass DetectDisplayClass(ILVariable v)
        {
            ITypeDefinition definition;
            if (v.Kind != VariableKind.StackSlot) {
                definition = v.Type.GetDefinition();
            } else if (v.StoreInstructions.Count > 0 && v.StoreInstructions[0] is StLoc stloc) {
                definition = stloc.Value.InferType(context.TypeSystem).GetDefinition();
            } else {
                definition = null;
            }
            if (!ValidateDisplayClassDefinition(definition))
                return null;
            DisplayClass result;
            switch (definition.Kind) {
                case TypeKind.Class:
                    if (!v.IsSingleDefinition)
                        return null;
                    if (!(v.StoreInstructions.SingleOrDefault() is StLoc stloc))
                        return null;
                    if (stloc.Value is NewObj newObj && ValidateConstructor(newObj.Method)) {
                        result = new DisplayClass(v, definition) {
                            CaptureScope = v.CaptureScope,
                            Initializer = stloc
                        };
                    } else {
                        return null;
                    }

                    HandleInitBlock(stloc.Parent as Block, stloc.ChildIndex + 1, result, result.Variable);
                    break;
예제 #2
0
        public IEnumerable <object> Get()
        {
            logData.Info("Get Assay Function is called");
            // getting back the assaytypes from the database table( AssayTypes)
            using (var repo = new AssayRepository())
            {
                try
                {
                    List <DisplayClass> objectAssay = new List <DisplayClass>();
                    var assaynamesobj = repo.GetAssay();
                    foreach (var assaytype in assaynamesobj)
                    {
                        DisplayClass ds = new DisplayClass();
                        ds.Id        = assaytype.ID;
                        ds.TypeId    = assaytype.TypeId;
                        ds.AssayName = assaytype.AssayName;
                        objectAssay.Add(ds);
                    }

                    logData.Info("Get Assay Function is finished");
                    return(objectAssay);
                }

                catch (SqlException odbcEx)
                {
                    Console.WriteLine(odbcEx.Message);
                    logData.Error(odbcEx.Message);
                    return(null);
                }
            }
        }
예제 #3
0
 // Constructors
 public Gigatronics854x()
     : base()
 {
     Display = new DisplayClass(this);
     Trigger = new TriggerClass(this);
     Sensors = new SensorCollectionClass(this);
 }
예제 #4
0
        public ActionResult Displays()
        {
            DisplayClass Stud = new DisplayClass();

            Stud.StudentNames = PopulateNames();
            return(View(Stud));
        }
예제 #5
0
        /// <summary>
        /// mcs likes to optimize closures in yield state machines away by moving the captured variables' fields into the state machine type,
        /// We construct a <see cref="DisplayClass"/> that spans the whole method body.
        /// </summary>
        bool HandleMonoStateMachine(ILFunction currentFunction, ILVariable thisVariable, SimpleTypeResolveContext decompilationContext, ILFunction nestedFunction)
        {
            if (!(nestedFunction.StateMachineCompiledWithMono && thisVariable.IsThis()))
            {
                return(false);
            }
            // Special case for Mono-compiled yield state machines
            ITypeDefinition closureType = thisVariable.Type.GetDefinition();

            if (!(closureType != decompilationContext.CurrentTypeDefinition &&
                  IsPotentialClosure(decompilationContext.CurrentTypeDefinition, closureType, allowTypeImplementingInterfaces: true)))
            {
                return(false);
            }

            var displayClass = new DisplayClass {
                IsMono       = true,
                Initializer  = nestedFunction.Body,
                Variable     = thisVariable,
                Definition   = thisVariable.Type.GetDefinition(),
                Variables    = new Dictionary <IField, ILVariable>(),
                CaptureScope = (BlockContainer)nestedFunction.Body
            };

            displayClasses.Add(thisVariable, displayClass);
            foreach (var stateMachineVariable in nestedFunction.Variables)
            {
                if (stateMachineVariable.StateMachineField == null || displayClass.Variables.ContainsKey(stateMachineVariable.StateMachineField))
                {
                    continue;
                }
                displayClass.Variables.Add(stateMachineVariable.StateMachineField, stateMachineVariable);
            }
            if (!currentFunction.Method.IsStatic && FindThisField(out var thisField))
            {
                var thisVar = currentFunction.Variables
                              .FirstOrDefault(t => t.IsThis() && t.Type.GetDefinition() == decompilationContext.CurrentTypeDefinition);
                if (thisVar == null)
                {
                    thisVar = new ILVariable(VariableKind.Parameter, decompilationContext.CurrentTypeDefinition, -1)
                    {
                        Name = "this"
                    };
                    currentFunction.Variables.Add(thisVar);
                }
                displayClass.Variables.Add(thisField, thisVar);
            }
            return(true);

            bool FindThisField(out IField foundField)
            {
                foundField = null;
                foreach (var field in closureType.GetFields(f2 => !f2.IsStatic && !displayClass.Variables.ContainsKey(f2) && f2.Type.GetDefinition() == decompilationContext.CurrentTypeDefinition))
                {
                    thisField = field;
                    return(true);
                }
                return(false);
            }
        }
예제 #6
0
        private void Btn_Click(object sender, System.EventArgs e)
        {
            EditText et = FindViewById <EditText>(Resource.Id.editText1);
            TextView tv = FindViewById <TextView>(Resource.Id.textView1);

            tv.Text = DisplayClass.DisplayInfo(et.Text);
        }
예제 #7
0
 private bool IsParameterAssignment(StObj inst, out DisplayClass displayClass, out IField field, out ILVariable parameter)
 {
     parameter = null;
     if (!IsDisplayClassFieldAccess(inst.Target, out var displayClassVar, out displayClass, out field))
     {
         return(false);
     }
     if (fieldAssignmentsWithVariableValue[field].Count != 1)
     {
         return(false);
     }
     if (!(inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && v.Function == currentFunction && v.Type.Equals(field.Type)))
     {
         return(false);
     }
     if (displayClass.Variables.ContainsKey((IField)field.MemberDefinition))
     {
         return(false);
     }
     if (displayClassVar.Function != currentFunction)
     {
         return(false);
     }
     parameter = v;
     return(true);
 }
예제 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;

            label2.Text = DisplayClass.DisplayInfo(name);
            MessageBox.Show(DisplayClass.DisplayInfo(name));
        }
예제 #9
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                YelpIServiceClient objSearch = new YelpIServiceClient();
                //Call the service.
                YelpSearchResult objYelp = objSearch.searchResults(txtSearchTerm.Text.ToString(), zipcode);

                List <DisplayClass> lstDisplay = new List <DisplayClass>();
                foreach (Business business in objYelp.lstBusiness)
                {
                    DisplayClass objDisplay = new DisplayClass();
                    objDisplay.Name     = business.name;
                    objDisplay.PhoneNo  = business.phone;
                    objDisplay.Location = string.Join(",", business.location.address) + ":" + business.location.city
                                          + ":" + business.location.state_code + "-" + business.location.postal_code;
                    lstDisplay.Add(objDisplay);
                }
                if (objYelp != null)
                {
                    resultGrid.DataSource = lstDisplay.ToArray();
                    resultGrid.DataBind();
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine("Exception : " + exp.Message);
            }
        }
예제 #10
0
 public static void AddAndDecorateOption(DiaOption opt, bool needsSocial, ref DisplayClass dc)
 {
     if (needsSocial && dc.negotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
     {
         opt.Disable("WorkTypeDisablesOption".Translate(SkillDefOf.Social.label));
     }
     dc.root.options.Add(opt);
 }
            public VariableToDeclare(DisplayClass container, IField field, ILVariable declaredVariable = null)
            {
                this.container        = container;
                this.field            = field;
                this.declaredVariable = declaredVariable;

                Debug.Assert(declaredVariable == null || declaredVariable.StateMachineField == field);
            }
 VariableToDeclare AddVariable(DisplayClass result, StObj statement, IField field)
 {
     VariableToDeclare variable = new VariableToDeclare(result, field);
     if (statement != null) {
         variable.Propagate(ResolveVariableToPropagate(statement.Value, field.Type));
         variable.Initializers.Add(statement);
     }
     return variable;
 }
예제 #13
0
        bool ValidateDisplayClassUses(ILVariable v, DisplayClass displayClass)
        {
            Debug.Assert(v == displayClass.Variable);
            foreach (var ldloc in v.LoadInstructions)
            {
                if (!ValidateUse(displayClass, ldloc))
                {
                    return(false);
                }
            }
            foreach (var ldloca in v.AddressInstructions)
            {
                if (!ValidateUse(displayClass, ldloca))
                {
                    return(false);
                }
            }
            return(true);

            bool ValidateUse(DisplayClass container, ILInstruction use)
            {
                IField field;

                switch (use.Parent)
                {
                case LdFlda ldflda when ldflda.MatchLdFlda(out var target, out field) && target == use:
                    var keyField = (IField)field.MemberDefinition;

                    if (!container.VariablesToDeclare.TryGetValue(keyField, out VariableToDeclare variable) || variable == null)
                    {
                        variable = AddVariable(container, null, field);
                    }
                    container.VariablesToDeclare[keyField] = variable;
                    return(true);

                case StObj stobj when stobj.MatchStObj(out var target, out ILInstruction value, out _) && value == use:
                    if (target.MatchLdFlda(out var load, out field) && load.MatchLdLocRef(out var otherVariable) && displayClasses.TryGetValue(otherVariable, out var otherDisplayClass))
                    {
                        if (otherDisplayClass.VariablesToDeclare.TryGetValue((IField)field.MemberDefinition, out var declaredVar))
                        {
                            return(declaredVar.CanPropagate);
                        }
                    }

                    return(false);

                case StLoc stloc when stloc.Variable.IsSingleDefinition && stloc.Value == use:
                    displayClassCopyMap[stloc.Variable] = v;
                    return(true);

                default:
                    return(false);
                }
            }
        }
예제 #14
0
        public static void CompiledVersion2()
        {
            IEnumerable <char> str    = "abcdefu";
            string             vowels = "aeiou";

            for (var i = 0; i < vowels.Length; i++)
            {
                DisplayClass dc = new DisplayClass();
                dc.i = i;
                str  = str.Where(dc.Func);
            }
            Console.WriteLine(new string(str.ToArray()));
        }
예제 #15
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder();

            builder.AddCommandLine(args, new Dictionary <string, string>
            {
                ["-Name"] = "Name"
            });

            var config = builder.Build();

            var name = config["Name"];

            Console.WriteLine(DisplayClass.DisplayInfo(name));
        }
예제 #16
0
        static Action GiveMeAction()
        {
            //Action ret = null;
            //int i = 5;
            //ret += () => i++;
            //ret += () => i += 2;
            // return ret;

            Action ret  = null;
            var    temp = new DisplayClass();

            ret += temp.Nameless1;
            ret += temp.Nameless2;

            return(ret);
        }
예제 #17
0
        internal static void CompiledReusedTranslationCache(AdventureWorks adventureWorks)
        {
            DisplayClass displayClass = new DisplayClass()
            {
                MinLength = 1
            };
            IQueryable <Product> queryWithClosure1 = adventureWorks.Products
                                                     .Where(product => product.Name.Length >= displayClass.MinLength);

            queryWithClosure1.Load();

            displayClass.MinLength = 10;
            IQueryable <Product> queryWithClosure2 = adventureWorks.Products
                                                     .Where(product => product.Name.Length >= displayClass.MinLength);

            queryWithClosure2.Load();
        }
예제 #18
0
 private bool IsDisplayClassAssignment(StObj inst, out DisplayClass displayClass, out IField field, out ILVariable variable)
 {
     variable = null;
     if (!IsDisplayClassFieldAccess(inst.Target, out var displayClassVar, out displayClass, out field))
     {
         return(false);
     }
     if (!(inst.Value.MatchLdLoc(out var v) && displayClasses.ContainsKey(v)))
     {
         return(false);
     }
     if (displayClassVar.Function != currentFunction)
     {
         return(false);
     }
     variable = v;
     return(true);
 }
예제 #19
0
        static void Main()
        {
            set_console_settings(size: 50);
            GameEngineClass gameEngine = new GameEngineClass();
            string          Command;
            bool            is_started = true;

            while (is_started)
            {
                Console.Write("Type command:\n" +
                              "Start = Start Game\n" +
                              "Info = Show Main info about program\n" +
                              "Load = Load Saved Game\n" +
                              "Exit = Exit From Game\n");
                Command = Console.ReadLine();
                switch (Command.ToLower())
                {
                case "start":
                    gameEngine.prepare_to_game();
                    gameEngine.start_game();
                    break;

                case "exit":
                    is_started = false;
                    break;

                case "info":
                    DisplayClass.show_program_info();
                    break;

                case "load":
                    gameEngine.load_game();
                    gameEngine.start_game();
                    break;

                default:
                    Console.WriteLine("Command Error!");
                    break;
                }
            }
        }
예제 #20
0
        // GET: api/AssayNamesReportFile
        public IEnumerable <object> Get()
        {
            logData.Info("Get Assay Name from Report File Function is called");
            // getting assay id from the database table( ReportFile)
            using (var repo = new AssayRepository())
            {
                try
                {
                    List <DisplayClass> objectAssay = new List <DisplayClass>();
                    List <long>         ids         = new List <long>();
                    List <long>         typeId      = new List <long>();
                    List <string>       assayNames  = new List <string>();
                    var assayobject = repo.GetAssayNameFromReportFile();
                    foreach (var assayName in assayobject)
                    {
                        DisplayClass ds = new DisplayClass();
                        ids.Add(assayName.AssayTypeId);
                        ds.Id = assayName.AssayTypeId;
                    }

                    //Using the assayId getting back the assay names
                    foreach (var assayid in ids)
                    {
                        DisplayClass ds = new DisplayClass();
                        ds.AssayName = repo.GetAssayName(assayid);
                        ds.TypeId    = repo.GetTypeIdWithID(assayid);
                        objectAssay.Add(ds);
                    }
                    return(objectAssay);
                }

                catch (SqlException odbcEx)
                {
                    Console.WriteLine(odbcEx.Message);
                    logData.Error(odbcEx.Message);
                    return(null);
                }
            }
        }
예제 #21
0
        public ActionResult Displays(DisplayClass Stud)
        {
            Stud.StudentNames = PopulateNames();
            if (Stud.ids != null)
            {
                List <SelectListItem> selectedItems = Stud.StudentNames.Where(p => Stud.ids.Contains(int.Parse(p.Value))).ToList();
                List <int>            StudentNoMail = new List <int>();
                ViewBag.Message = "Selected Student:";
                foreach (var selectedItem in selectedItems)
                {
                    var intno = Convert.ToInt32(selectedItem.Value);
                    selectedItem.Selected = true;

                    StudentNoMail.Add(intno);
                }
                Session["MailTransfer"] = StudentNoMail;
                return(RedirectToAction("Mail", "Email"));
            }
            else
            {
                return(RedirectToAction("Displays"));
            }
        }
예제 #22
0
        /// <summary>
        /// Method to generate the code to implement the type
        /// </summary>
        /// <returns></returns>
        public override CodeTypeDeclaration GetCodeType()
        {
            CodeTypeDeclaration type = new CodeTypeDeclaration(Name);

            type.IsClass = true;
            type.BaseTypes.Add(new CodeTypeReference(typeof(BaseParser)));
            type.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            type.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(GuidAttribute)),
                                                                   new CodeAttributeArgument(new CodePrimitiveExpression(Uuid.ToString()))));

            if (DisplayClass != Guid.Empty)
            {
                type.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DisplayClassAttribute)),
                                                                       new CodeAttributeArgument(new CodePrimitiveExpression(DisplayClass.ToString()))));
            }

            if (!String.IsNullOrWhiteSpace(_formatString))
            {
                type.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(FormatStringAttribute)),
                                                                       new CodeAttributeArgument(new CodePrimitiveExpression(_formatString))));
            }

            CodeConstructor defaultConstructor = new CodeConstructor();

            defaultConstructor.Attributes = MemberAttributes.Public;
            type.Members.Add(defaultConstructor);

            CodeConstructor fromStreamConstructor = new CodeConstructor();

            fromStreamConstructor.Attributes = MemberAttributes.Public;
            fromStreamConstructor.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(DataReader)), "reader"));
            fromStreamConstructor.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(StateDictionary)), "state"));
            fromStreamConstructor.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(Logger)), "logger"));

            fromStreamConstructor.BaseConstructorArgs.Add(CodeGen.GetArgument("reader"));
            fromStreamConstructor.BaseConstructorArgs.Add(CodeGen.GetArgument("state"));
            fromStreamConstructor.BaseConstructorArgs.Add(CodeGen.GetArgument("logger"));
            type.Members.Add(fromStreamConstructor);

            CodeMemberMethod preSerializer = new CodeMemberMethod();

            preSerializer.Name       = "PreSerializer";
            preSerializer.Attributes = MemberAttributes.Private;

            CodeMemberMethod postSerializer = new CodeMemberMethod();

            postSerializer.Name       = "PostSerializer";
            postSerializer.Attributes = MemberAttributes.Private;

            CodeMemberMethod preDeserializer = new CodeMemberMethod();

            preDeserializer.Name       = "PreDeserializer";
            preDeserializer.Attributes = MemberAttributes.Private;

            CodeMemberMethod postDeserializer = new CodeMemberMethod();

            postDeserializer.Name       = "PostDeserializer";
            postDeserializer.Attributes = MemberAttributes.Private;

            CodeMemberMethod fromStreamMethod = new CodeMemberMethod();

            fromStreamMethod.Name       = "FromStream";
            fromStreamMethod.Attributes = MemberAttributes.Public | MemberAttributes.Override;

            CodeMemberMethod toStreamMethod = new CodeMemberMethod();

            toStreamMethod.Name       = "ToStream";
            toStreamMethod.Attributes = MemberAttributes.Public | MemberAttributes.Override;

            if (PreserializeExpression.IsValid)
            {
                toStreamMethod.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), "Resolve", CodeGen.GetPrimitive(PreserializeExpression.Expression)));
            }

            foreach (MemberEntry entry in Members)
            {
                IMemberReaderWriter readerWriter = entry as IMemberReaderWriter;
                CodeMemberField     field        = entry.GetMemberDeclaration();
                if (entry.Hidden)
                {
                    field.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(HiddenMemberAttribute)),
                                                                            new CodeAttributeArgument(CodeGen.GetPrimitive(true))));
                }

                if (entry.ReadOnly)
                {
                    field.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(ReadOnlyMemberAttribute)),
                                                                            new CodeAttributeArgument(CodeGen.GetPrimitive(true))));
                }

                if (entry.DisplayClass != Guid.Empty)
                {
                    field.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DisplayClassAttribute)),
                                                                            new CodeAttributeArgument(CodeGen.GetPrimitive(entry.DisplayClass.ToString()))));
                }

                type.Members.Add(field);

                CodeMemberMethod serMethod       = entry.GetSerializerMethod();
                CodeMemberMethod deserMethod     = entry.GetDeserializerMethod();
                CodeMemberMethod preserMethod    = entry.GetPreSerializeMethod();
                CodeMemberMethod postserMethod   = entry.GetPostSerializeMethod();
                CodeMemberMethod predeserMethod  = entry.GetPreDeserializeMethod();
                CodeMemberMethod postdeserMethod = entry.GetPostDeserializeMethod();

                if (readerWriter == null)
                {
                    type.Members.Add(serMethod);
                    type.Members.Add(deserMethod);
                }

                if (preserMethod.Statements.Count > 0)
                {
                    type.Members.Add(preserMethod);
                    preSerializer.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), preserMethod.Name));
                }

                if (postserMethod.Statements.Count > 0)
                {
                    type.Members.Add(postserMethod);
                    postSerializer.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), postserMethod.Name));
                }

                if (predeserMethod.Statements.Count > 0)
                {
                    type.Members.Add(predeserMethod);
                    preDeserializer.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(),
                                                                      predeserMethod.Name));
                }

                if (postdeserMethod.Statements.Count > 0)
                {
                    type.Members.Add(postdeserMethod);
                    postDeserializer.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(),
                                                                       postserMethod.Name));
                }

                CodeStatement readStatement  = null;
                CodeStatement writeStatement = null;

                if (readerWriter != null)
                {
                    CodeExpression readExpression = readerWriter.GetReaderExpression(GetReader());

                    if (entry.ValidateExpression.IsValid)
                    {
                        readExpression = CodeGen.CallMethod(CodeGen.GetThis(), "V", readExpression, CodeGen.GetPrimitive(entry.ValidateExpression.Expression));
                    }

                    readStatement =
                        CodeGen.GetAssign(CodeGen.GetThisField(field.Name), readExpression);

                    writeStatement =
                        new CodeExpressionStatement(readerWriter.GetWriterExpression(GetWriter(), CodeGen.GetThisField(field.Name)));
                }
                else
                {
                    CodeExpression readExpression = CodeGen.CallMethod(CodeGen.GetThis(), deserMethod.Name, GetReader());

                    if (entry.ValidateExpression.IsValid)
                    {
                        readExpression = CodeGen.CallMethod(CodeGen.GetThis(), "V", readExpression, CodeGen.GetPrimitive(entry.ValidateExpression.Expression));
                    }

                    readStatement =
                        CodeGen.GetAssign(CodeGen.GetThisField(field.Name), readExpression);

                    writeStatement =
                        new CodeExpressionStatement(CodeGen.CallMethod(CodeGen.GetThis(), serMethod.Name,
                                                                       GetWriter(),
                                                                       CodeGen.GetThisField(field.Name)));
                }

                if (entry.OptionalExpression.IsValid)
                {
                    readStatement  = CodeGen.GetIf(entry.OptionalExpression.GetCheckExpression(), new[] { readStatement });
                    writeStatement = CodeGen.GetIf(entry.OptionalExpression.GetCheckExpression(), new[] { writeStatement });
                }

                fromStreamMethod.Statements.Add(readStatement);
                toStreamMethod.Statements.Add(writeStatement);
            }

            if (preDeserializer.Statements.Count > 0)
            {
                fromStreamMethod.Statements.Insert(0, CodeGen.GetStatement(CodeGen.CallMethod(CodeGen.GetThis(), "PreDeserializer")));
                type.Members.Add(preDeserializer);
            }

            toStreamMethod.Statements.Add(new CodeMethodInvokeExpression(GetWriter(), "Flush"));
            if (preSerializer.Statements.Count > 0)
            {
                toStreamMethod.Statements.Insert(0, CodeGen.GetStatement(CodeGen.CallMethod(CodeGen.GetThis(), "PreSerializer")));
                type.Members.Add(preSerializer);
            }

            if (postDeserializer.Statements.Count > 0)
            {
                fromStreamMethod.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), "PostDeserializer"));
                type.Members.Add(postDeserializer);
            }

            if (PostDeserializeExpression.IsValid)
            {
                fromStreamMethod.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), "Resolve", CodeGen.GetPrimitive(PostDeserializeExpression.Expression)));
            }

            if (postSerializer.Statements.Count > 0)
            {
                toStreamMethod.Statements.Add(CodeGen.CallMethod(CodeGen.GetThis(), "PostSerializer"));
                type.Members.Add(postSerializer);
            }

            type.Members.Add(fromStreamMethod);
            type.Members.Add(toStreamMethod);

            return(type);
        }
예제 #23
0
 private bool IsDisplayClassFieldAccess(ILInstruction inst, out ILVariable displayClassVar, out DisplayClass displayClass, out IField field)
 {
     displayClass    = null;
     displayClassVar = null;
     field           = null;
     if (!(inst is LdFlda ldflda))
     {
         return(false);
     }
     field = ldflda.Field;
     return(IsDisplayClassLoad(ldflda.Target, out displayClassVar) &&
            displayClasses.TryGetValue(displayClassVar, out displayClass));
 }
예제 #24
0
 public MvcHtmlString SubmitButton(string text, DisplayClass btnClass = DisplayClass.@default, ButtonSize?size = null)
 {
     return(page.Html.Partial("Bootstrap.Button", BootstrapButton.Create(ButtonType.submit, text, btnClass, size)));
 }
예제 #25
0
        /// <summary>
        /// Generate the code for the type
        /// </summary>
        /// <returns></returns>
        public override System.CodeDom.CodeTypeDeclaration GetCodeType()
        {
            CodeTypeDeclaration ret = new CodeTypeDeclaration(Name);

            ret.BaseTypes.Add(typeof(long));
            ret.IsEnum = true;
            if (IsFlags)
            {
                ret.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(FlagsAttribute))));
            }
            ret.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(GuidAttribute)),
                                                                  new CodeAttributeArgument(new CodePrimitiveExpression(Uuid.ToString()))));
            if (DisplayClass != Guid.Empty)
            {
                ret.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DisplayClassAttribute)),
                                                                      new CodeAttributeArgument(new CodePrimitiveExpression(DisplayClass.ToString()))));
            }
            ret.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(SerializableAttribute))));

            foreach (EnumParserTypeEntry entry in Entries)
            {
                CodeMemberField field = new CodeMemberField(Name, entry.Name);
                field.InitExpression = new CodePrimitiveExpression(entry.Value);
                ret.Members.Add(field);
            }

            return(ret);
        }
예제 #26
0
 public static BootstrapButton Create(ButtonType type, string text, DisplayClass bnClass = DisplayClass.@default, ButtonSize?size = null)
 {
     return(new BootstrapButton {
         Type = type, Text = text, ButtonClass = bnClass, Size = size
     });
 }
예제 #27
0
        public static DiaNode FactionDialogFor(Pawn negotiator, Faction faction)
        {
            MethodBase RequestRoyalHeirChangeOption = AccessTools.Method(typeof(FactionDialogMaker), "RequestRoyalHeirChangeOption", null, null);
            MethodBase RoyalHeirChangeConfirm       = AccessTools.Method(typeof(FactionDialogMaker), "RoyalHeirChangeConfirm", null, null);
            MethodBase RoyalHeirChangeCandidates    = AccessTools.Method(typeof(FactionDialogMaker), "RoyalHeirChangeCandidates", null, null);
            MethodBase RequestAICoreQuest           = AccessTools.Method(typeof(FactionDialogMaker), "RequestAICoreQuest", null, null);
            MethodBase DebugOptions = AccessTools.Method(typeof(FactionDialogMaker), "DebugOptions", null, null);

            DisplayClass dc0 = default(DisplayClass);
            Map          map = negotiator.Map;
            Pawn         pawn;
            string       value;

            if (faction.leader != null)
            {
                pawn  = faction.leader;
                value = faction.leader.Name.ToStringFull.Colorize(ColoredText.NameColor);
            }
            else
            {
                pawn  = dc0.negotiator;
                value = faction.Name;
            }
            if (faction.PlayerRelationKind == FactionRelationKind.Hostile)
            {
                string key = (faction.def.permanentEnemy || !"FactionGreetingHostileAppreciative".CanTranslate()) ? "FactionGreetingHostile" : "FactionGreetingHostileAppreciative";
                dc0.root = new DiaNode(key.Translate(value).AdjustedFor(pawn));
            }
            else if (faction.PlayerRelationKind == FactionRelationKind.Neutral)
            {
                dc0.root = new DiaNode("FactionGreetingWary".Translate(value, dc0.negotiator.LabelShort, dc0.negotiator.Named("NEGOTIATOR"), pawn.Named("LEADER")).AdjustedFor(pawn));
            }
            else
            {
                dc0.root = new DiaNode("FactionGreetingWarm".Translate(value, dc0.negotiator.LabelShort, dc0.negotiator.Named("NEGOTIATOR"), pawn.Named("LEADER")).AdjustedFor(pawn));
            }
            if (map != null && map.IsPlayerHome)
            {
                AddAndDecorateOption(RequestTraderOption(map, faction, dc0.negotiator), true, ref dc0);
                AddAndDecorateOption(RequestMilitaryAid_Scouts_Option(map, faction, dc0.negotiator), true, ref dc0);
                AddAndDecorateOption(RequestMilitaryAid_Warband_Option(map, faction, dc0.negotiator), true, ref dc0);
                Pawn_RoyaltyTracker royalty = dc0.negotiator.royalty;
                if (royalty != null && royalty.HasAnyTitleIn(faction))
                {
                    foreach (RoyalTitle item in royalty.AllTitlesInEffectForReading)
                    {
                        if (item.def.permits != null)
                        {
                            foreach (RoyalTitlePermitDef permit in item.def.permits)
                            {
                                IEnumerable <DiaOption> factionCommDialogOptions = permit.Worker.GetFactionCommDialogOptions(map, dc0.negotiator, faction);
                                if (factionCommDialogOptions != null)
                                {
                                    foreach (DiaOption item2 in factionCommDialogOptions)
                                    {
                                        AddAndDecorateOption(item2, true, ref dc0);
                                    }
                                }
                            }
                        }
                    }
                    if (royalty.GetCurrentTitle(faction).canBeInherited&& !dc0.negotiator.IsQuestLodger())
                    {
                        AddAndDecorateOption((DiaOption)RequestRoyalHeirChangeOption.Invoke((object)typeof(FactionDialogMaker), new object[]
                                                                                            { map, faction, pawn, dc0.negotiator }), true, ref dc0);
                    }
                }
                if (DefDatabase <ResearchProjectDef> .AllDefsListForReading.Any(delegate(ResearchProjectDef rp)
                {
                    if (rp.HasTag(ResearchProjectTagDefOf.ShipRelated))
                    {
                        return(rp.IsFinished);
                    }
                    return(false);
                }))
                {
                    AddAndDecorateOption((DiaOption)RequestAICoreQuest.Invoke((object)typeof(FactionDialogMaker), new object[]
                                                                              { map, faction, dc0.negotiator }), true, ref dc0);
                }
            }
            if (Prefs.DevMode)
            {
                foreach (DiaOption item3 in (IEnumerable <DiaOption>)DebugOptions.Invoke((object)typeof(FactionDialogMaker), new object[]
                                                                                         { faction, dc0.negotiator }))
                {
                    AddAndDecorateOption(item3, false, ref dc0);
                }
            }
            AddAndDecorateOption(new DiaOption("(" + "Disconnect".Translate() + ")")
            {
                resolveTree = true
            }, false, ref dc0);
            return(dc0.root);
        }