Пример #1
0
        public async Task LoadNamesAsync(int currentCount, int defaultTakeCount, string webServerUrl)
        {
            //Console.WriteLine($"Loading new names {currentCount}");
            var service = new NameService(webServerUrl);

            People = await service.GetDistinct(currentCount, defaultTakeCount, false);
        }
Пример #2
0
        internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer)
        {
            if (def is TypeDef)
                Analyze(service, context, parameters, (TypeDef)def);
            else if (def is MethodDef)
                Analyze(service, context, parameters, (MethodDef)def);
            else if (def is FieldDef)
                Analyze(service, context, parameters, (FieldDef)def);
            else if (def is PropertyDef)
                Analyze(service, context, parameters, (PropertyDef)def);
            else if (def is EventDef)
                Analyze(service, context, parameters, (EventDef)def);
            else if (def is ModuleDef) {
                var pass = parameters.GetParameter<string>(context, def, "password", null);
                if (pass != null)
                    service.reversibleRenamer = new ReversibleRenamer(pass);
                service.SetCanRename(def, false);
            }

            if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false))
                return;

            foreach (IRenamer renamer in service.Renamers)
                renamer.Analyze(context, service, parameters, def);
        }
Пример #3
0
        public void PromiseStringIsAsyncCall()
        {
            var type    = CreateSingleParameterGeneric("Promise", "string");
            var isAsync = NameService.IsAsync(type);

            Assert.IsTrue(isAsync);
        }
Пример #4
0
        public void GenericTypes(string genericType, string typeParameter1, string expectedType)
        {
            var type = CreateSingleParameterGeneric(genericType, typeParameter1);
            var name = NameService.GetTypeName(type);

            Assert.AreEqual(expectedType, name);
        }
Пример #5
0
        public void VibratePatternConverToNumberArray()
        {
            var type = CreateTypeDefinition("VibratePattern");
            var name = NameService.GetTypeName(type);

            Assert.AreEqual("int[]", name);
        }
Пример #6
0
        public void RegularTypes(string idlType, string csharpType)
        {
            var type = CreateTypeDefinition(idlType);
            var name = NameService.GetTypeName(type);

            Assert.AreEqual(csharpType, name);
        }
Пример #7
0
        public void GenericIsNotAsyncCall()
        {
            var type    = CreateSingleParameterGeneric("NonPromise", "string");
            var isAsync = NameService.IsAsync(type);

            Assert.IsFalse(isAsync);
        }
Пример #8
0
        public void VoidIsNotAsyncCall()
        {
            var type    = CreateTypeDefinition("void");
            var isAsync = NameService.IsAsync(type);

            Assert.IsFalse(isAsync);
        }
Пример #9
0
 protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
 {
     foreach (ModuleDef moduleDef in parameters.Targets.OfType <ModuleDef>())
     {
         ModuleDefMD moduleDefMD = (ModuleDefMD)moduleDef;
         if (moduleDefMD.FullName.Contains(".exe"))
         {
             int num = context.Modules.Count - 1;
             for (int i = 0; i <= num; i++)
             {
                 for (int j = 0; j <= 50; j++)
                 {
                     Random rnd = new Random();
                     new TypeDefUser(NameService.RandomNameStatic(), moduleDefMD.CorLibTypes.Object.TypeDefOrRef).Attributes = TypeAttributes.Public;
                     TypeDef item = new TypeDefUser(NameService.RandomNameStatic(), NameService.RandomNameStatic(), moduleDefMD.CorLibTypes.Object.TypeDefOrRef)
                     {
                         Attributes = TypeAttributes.Public
                     };
                     TypeDef item2 = new TypeDefUser(NameService.RandomNameStatic(), NameService.RandomNameStatic(), moduleDefMD.CorLibTypes.Object.TypeDefOrRef)
                     {
                         Attributes = TypeAttributes.Public
                     };
                     moduleDefMD.Types.Add(item);
                     moduleDefMD.Types.Add(item2);
                 }
                 Random rnd1 = new Random();
             }
         }
         else
         {
             context.Logger.Log("WARN: Junk cannot be used on a dll");
         }
     }
 }
Пример #10
0
        public static void AddNewFurnitureToMarket(int count)
        {
            var furnRepo = new EFFurnitureRepository();

            var rand = new Random();

            for (var i = 0; i < count; i++)
            {
                var furnitureTypes = furnRepo.DbStaticFurniture.ToList();
                var max            = furnitureTypes.Count();
                var num            = rand.NextDouble();

                var index         = Convert.ToInt32(Math.Floor(num * max));
                var furnitureType = furnitureTypes[index];

                var contractTurnRandomOffset = (int)(furnitureType.BaseContractTurnLength * ((rand.NextDouble() - .5) * 2) * FurnitureContractVariation);
                var basePriceRandomOffset    = furnitureType.BaseCost * (decimal)((rand.NextDouble() - .5) * 2) * (decimal)FurnitureContractVariation;

                var newfurn = new Furniture
                {
                    dbType = furnitureType.dbType,
                    ContractTurnDuration = furnitureType.BaseContractTurnLength + contractTurnRandomOffset,
                    CovenantId           = -1,
                    HumanName            = $"{NameService.GetRandomFirstName()} {NameService.GetRandomLastName()} the {furnitureType.FriendlyName}",
                    Price             = Math.Floor(furnitureType.BaseCost + basePriceRandomOffset),
                    LastUseTimestamp  = DateTime.UtcNow,
                    ContractStartTurn = 0,
                    ContractEndTurn   = 0,
                    LastUsersIds      = ";",
                };

                furnRepo.SaveFurniture(newfurn);
            }
        }
Пример #11
0
        public void TestGetName(string expected, string title)
        {
            var nameService = new NameService();
            var result      = nameService.GetName(title);

            Assert.Equal(expected, result);
        }
Пример #12
0
 /* When the Remove model button is pressed */
 private void RemoveModelButton_Click(object sender, EventArgs e)
 {
     if (this.wObj.GetService(typeof(Model)) != null)
     {
         RenderSubsystem render = (RenderSubsystem)this.createWorld.game.Services.GetService(typeof(RenderSubsystem));
         if (this.wObj.ContainService(typeof(NameService)))
         {
             NameService name = (NameService)this.wObj.GetService(typeof(NameService));
             render.DrawServices.Remove(name.ObjectName());
             this.wObj.RemoveService(typeof(Model));
             this.wObj.RemoveService(typeof(DrawService));
             this.StringModel.Text = "";
             if (System.IO.Directory.Exists(this.createWorld.contentBuilder.OutputDirectory + "\\" + name.ObjectName() + ".xnb"))
             {
                 System.IO.Directory.Delete(this.createWorld.contentBuilder.OutputDirectory + "\\" + name.ObjectName() + ".xnb");
             }
         }
     }
     else
     {
         if (this.wObj.ContainService(typeof(NameService)))
         {
             NameService name = (NameService)this.wObj.GetService(typeof(NameService));
             this.StringModel.Text = "";
             if (System.IO.Directory.Exists(this.createWorld.contentBuilder.OutputDirectory + "\\" + name.ObjectName() + ".xnb"))
             {
                 System.IO.Directory.Delete(this.createWorld.contentBuilder.OutputDirectory + "\\" + name.ObjectName() + ".xnb");
             }
         }
     }
 }
Пример #13
0
        public async Task <JsonResult> AjaxRequest(NameType?nameType, NameGender?nameGender, int limit)
        {
            if (nameType == null && nameGender == null)
            {
                nameList = await NameService.GetNameList(limit);

                return(Json(nameList));
            }
            else if (nameType == null && nameGender != null)
            {
                nameList = await NameService.GetNameList(nameGender, limit);

                return(Json(nameList));
            }
            else if (nameGender == null && nameType != null)
            {
                nameList = await NameService.GetNameList(nameType, limit);

                return(Json(nameList));
            }
            else
            {
                nameList = await NameService.GetNameList(nameType, nameGender, limit);

                return(Json(nameList));
            }
        }
Пример #14
0
        public async Task <ActionResult> Index()
        {
            //Default request när sidan laddas
            nameList = await NameService.GetNameList(10);

            return(View(nameList));
        }
Пример #15
0
        public async Task <ActionResult> UpdateRequest(NameType?nameType, NameGender?nameGender, int limit)
        {
            if (nameType == null && nameGender == null)
            {
                nameList = await NameService.GetNameList(limit);

                return(View("Index", nameList));
            }
            else if (nameType == null && nameGender != null)
            {
                nameList = await NameService.GetNameList(nameGender, limit);

                return(View("Index", nameList));
            }
            else if (nameGender == null && nameType != null)
            {
                nameList = await NameService.GetNameList(nameType, limit);

                return(View("Index", nameList));
            }
            else
            {
                nameList = await NameService.GetNameList(nameType, nameGender, limit);

                return(View("Index", nameList));
            }
        }
Пример #16
0
        public override void Initialize(IServiceProvider provider, VirtualWorld VW)
        {
            var wo       = (IServiceContainer)provider.GetService(typeof(IServiceContainer));
            var nameServ = new NameService(wo, VW, name);

            wo.AddService(typeof(NameService), nameServ);
        }
        public UpdateWithFlyOptomotorResponse(IServiceContainer wObj, Game game)
            : base(wObj, game)
        {
            //load all necessary services
            flyPos  = (KalmanFilterTrack)game.Services.GetService(typeof(KalmanFilterTrack));
            posServ = (PositionService)wObj.GetService(typeof(PositionService));
            pType   = (VRProtocol)game.Services.GetService(typeof(VRProtocol));
            name    = (NameService)wObj.GetService(typeof(NameService));
            if ((UpdateSubsystem)game.Services.GetService(typeof(UpdateSubsystem)) != null)
            {
                //add this update service to the update subsystem list
                UpdateSubsystem us = (UpdateSubsystem)game.Services.GetService(typeof(UpdateSubsystem));
                us.AddUpdateService(name.ObjectName() + "UpdateWithFlyOptomotorResponse", this);
            }
            pType.pType = VRProtocolType.ClosedLoop;

            //calibration values
            c[0]  = 0.0012f;
            c[1]  = -0.8937f;
            c[2]  = 0.0000f;
            c[3]  = 0.0005f;
            c[4]  = 1;
            c[5]  = 0.0013f;
            c[6]  = -0.0000f;
            c[7]  = -0.3741f;
            c[8]  = 11.6243f;
            c[9]  = 5.6421f;
            c[10] = -12.9017f;
            c[11] = -0.9338f;

            //protocol trial structure load (pre-defined)
            frames   = GetFrames();
            protocol = GetProtocol();
        }
Пример #18
0
        public override void Initialize(IServiceProvider provider, Game game)
        {
            var name = new NameService(objectName, game);
            var wo   = (IServiceContainer)provider.GetService(typeof(IServiceContainer));

            wo.AddService(typeof(NameService), name);
        }
Пример #19
0
		void RegisterRenamers(ConfuserContext context, NameService service) {
			bool wpf = false,
			     caliburn = false,
			     winforms = false;

			foreach (var module in context.Modules)
				foreach (var asmRef in module.GetAssemblyRefs()) {
					if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" ||
					    asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") {
						wpf = true;
					}
					else if (asmRef.Name == "Caliburn.Micro") {
						caliburn = true;
					}
					else if (asmRef.Name == "System.Windows.Forms") {
						winforms = true;
					}
				}

			if (wpf) {
				var wpfAnalyzer = new WPFAnalyzer();
				context.Logger.Debug("WPF found, enabling compatibility.");
				service.Renamers.Add(wpfAnalyzer);
				if (caliburn) {
					context.Logger.Debug("Caliburn.Micro found, enabling compatibility.");
					service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer));
				}
			}

			if (winforms) {
				var winformsAnalyzer = new WinFormsAnalyzer();
				context.Logger.Debug("WinForms found, enabling compatibility.");
				service.Renamers.Add(winformsAnalyzer);
			}
		}
Пример #20
0
        public static void Main(string[] args)
        {
            INameService nameService = new NameService();

            Console.Write(nameService.GetName());

            Console.ReadKey();
        }
Пример #21
0
        public void DeleteGameByName_ReturnsValidationException_DALChangeValue()
        {
            // Arrange
            var sut = new NameService <Game, GameDTO, GameTranslate, GameDTOTranslate>(_mock.Object);

            // Act
            Assert.Throws <ValidationException>(() => sut.DeleteByName("name"));
        }
Пример #22
0
        public void FindEmployee_nonExistingEmployee_expectsNull()
        {
            ILogger <EmployeeControl> logger = Mock.Of <ILogger <EmployeeControl> >();
            INameService    nameService      = new NameService();
            IEventProducer  eventProducer    = Mock.Of <IEventProducer>();
            EmployeeControl employeeControl  = new EmployeeControl(nameService, logger, eventProducer);

            Assert.True(employeeControl.FindEmployeeByName("First", "Last") == null);
        }
Пример #23
0
 public ModerationModule(
     TimeoutService timeout,
     NameService name,
     MessageService message)
 {
     this.timeout = timeout;
     this.name    = name;
     this.message = message;
 }
Пример #24
0
        public async Task <List <PersonViewModel> > UpdateQueueAsync(int currentCount, int defaultTakeCount, string webServerUrl)
        {
            //Console.WriteLine($"Loading secondary new names {currentCount}");
            var service = new NameService(webServerUrl);

            Queue = await service.GetDistinct(currentCount, defaultTakeCount, false);

            return(Queue);
        }
Пример #25
0
        /* Remove a World Object from the World Object list of its parent */
        public void RemoveParent(TreeNode node, TreeNode parentNode)
        {
            WorldObject worldObj = (WorldObject)parentNode.Tag;
            WorldObject objj     = (WorldObject)node.Tag;
            NameService nameC    = (NameService)objj.GetService(typeof(NameService));

            worldObj.RemoveWorldObject(nameC.ObjectName());
            parentNode.Tag = worldObj;
        }
Пример #26
0
        public ActionResult Index()
        {
            // starting limit of 10 names with NameType=Both and NameGender=Both
            int limit = 10;

            // Getting the list from the NameAPI library
            nameList = NameService.GetNameList(limit);
            return(View(nameList));
        }
Пример #27
0
        private string NewName(string name)
        {
            string newName;

            if (!nameMap.TryGetValue(name, out newName))
            {
                nameMap[name] = newName = NameService.RandomNameStatic();
            }
            return(newName);
        } //you need to change this method, i use NameService so i don't have to do the renamer method again
Пример #28
0
 public ItemGenerator()
 {
     _initializer        = new Initializer();
     _propertyService    = new PropertyService();
     _levelService       = new LevelService();
     _nameService        = new NameService();
     _rarityService      = new RarityService();
     _calculationService = new CalculationService();
     _socketService      = new SocketService();
 }
Пример #29
0
 // Remove a child WorldObject from the WorldObject list using its name
 public void RemoveWorldObject(string str)
 {
     foreach (WorldObject obj in WObjects)
     {
         NameService Name = (NameService)obj.GetService(typeof(NameService));
         if (str == Name.ObjectName())
         {
             WObjects.Remove(obj);
         }
     }
 }
Пример #30
0
 /* Method that converts a Name Service to a Name Service */
 public void NameServiceToNameFactory(WorldObject wObji, WorldObject wObjf)
 {
     if (wObji.ContainService(typeof(NameService)))
     {
         NameService name     = (NameService)wObji.GetService(typeof(NameService));
         NameFactory nameFact = new NameFactory();
         nameFact.objectName = name.name;
         /* Save the factory in the object builder list */
         wObjf.objectBuilder.Add(nameFact);
     }
 }
Пример #31
0
        public ActionResult Reload(NameGender gender, NameType type, int limit)
        {
            // storing the choises in the predefined variables
            ctrlGender = gender;
            ctrlType   = type;
            ctrlLimit  = limit;

            // Getting the list from the NameAPI library
            nameList = NameService.GetNameList(type, gender, limit);
            return(View("Index", nameList));
        }
Пример #32
0
 // Get a child WorldObject from the WorldObject list using its name
 public WorldObject GetWorldObject(string str)
 {
     foreach (WorldObject obj in WObjects)
     {
         NameService Name = (NameService)obj.GetService(typeof(NameService));
         if (str == Name.ObjectName())
         {
             return(obj);
         }
     }
     return(null);
 }
Пример #33
0
        private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type)
        {
            if (type.IsVisibleOutside() && !parameters.GetParameter<bool>(context, type, "renPublic", false)) {
                service.SetCanRename(type, false);
            }
            else if (type.IsRuntimeSpecialName || type.IsSpecialName) {
                service.SetCanRename(type, false);
            }
            else if (type.FullName == "ConfusedByAttribute") {
                // Courtesy
                service.SetCanRename(type, false);
            }

            if (parameters.GetParameter<bool>(context, type, "forceRen", false))
                return;

            if (type.InheritsFromCorlib("System.Attribute")) {
                service.ReduceRenameMode(type, RenameMode.ASCII);
            }
        }
Пример #34
0
        internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer)
        {
            if (def is TypeDef)
                Analyze(service, context, parameters, (TypeDef)def);
            else if (def is MethodDef)
                Analyze(service, context, parameters, (MethodDef)def);
            else if (def is FieldDef)
                Analyze(service, context, parameters, (FieldDef)def);
            else if (def is PropertyDef)
                Analyze(service, context, parameters, (PropertyDef)def);
            else if (def is EventDef)
                Analyze(service, context, parameters, (EventDef)def);
            else if (def is ModuleDef)
                service.SetCanRename(def, false);

            if (!runAnalyzer || parameters.GetParameter<bool>(context, def, "forceRen", false))
                return;

            foreach (IRenamer renamer in service.Renamers)
                renamer.Analyze(context, service, def);
        }
Пример #35
0
        static void Main(string[] args)
        {
            int ownID = 1;
            string chatterName = null;
            int domain = DDS.DomainId.Default;
            string partitionName = "ChatRoom";

            /* Options: Chatter [ownID [name]] */
            if (args.Length > 0)
            {
                ownID = int.Parse(args[0]);
                if (args.Length > 1)
                {
                    chatterName = args[1];
                }
            }
                 
            /* Create a DomainParticipantFactory and a DomainParticipant
               (using Default QoS settings. */
            DomainParticipantFactory dpf = DomainParticipantFactory.Instance;
            ErrorHandler.checkHandle(dpf, "DDS.DomainParticipantFactory.Instance");

            IDomainParticipant participant = dpf.CreateParticipant(domain, null, StatusKind.Any);
            ErrorHandler.checkHandle(participant, "DDS.DomainParticipantFactory.CreateParticipant");

            /* Register the required datatype for ChatMessage. */
            ChatMessageTypeSupport chatMessageTS = new ChatMessageTypeSupport();
            string chatMessageTypeName = chatMessageTS.TypeName;
            ReturnCode status = chatMessageTS.RegisterType(
                participant, chatMessageTypeName);
            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageTypeSupport.RegisterType");

            /* Register the required datatype for NameService. */
            NameServiceTypeSupport nameServiceTS = new NameServiceTypeSupport();
            string nameServiceTypeName = nameServiceTS.TypeName;
            status = nameServiceTS.RegisterType(
                participant, nameServiceTypeName);
            ErrorHandler.checkStatus(
                status, "Chat.NameServiceTypeSupport.RegisterType");

            /* Initialise Qos variables */
            TopicQos reliableTopicQos = new TopicQos();
            TopicQos settingTopicQos = new TopicQos();
            PublisherQos pubQos = new PublisherQos();
            DataWriterQos dwQos = new DataWriterQos();
            DataWriterQos nsDwQos = new DataWriterQos();

            /* Set the ReliabilityQosPolicy to RELIABLE. */
            status = participant.GetDefaultTopicQos(ref reliableTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.GetDefaultTopicQos");
            reliableTopicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;

            /* Make the tailored QoS the new default. */
            status = participant.SetDefaultTopicQos(reliableTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.SetDefaultTopicQos");

            /* Use the changed policy when defining the ChatMessage topic */
            ITopic chatMessageTopic = participant.CreateTopic(
                "Chat_ChatMessage",
                chatMessageTypeName,
                reliableTopicQos);
            ErrorHandler.checkHandle(
                chatMessageTopic,
                "DDS.DomainParticipant.CreateTopic (ChatMessage)");

            /* Set the DurabilityQosPolicy to TRANSIENT. */
            status = participant.GetDefaultTopicQos(ref settingTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.GetDefaultTopicQos");
            settingTopicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;

            /* Create the NameService Topic. */
            ITopic nameServiceTopic = participant.CreateTopic(
                "Chat_NameService",
                nameServiceTypeName,
                settingTopicQos);
            ErrorHandler.checkHandle(
                nameServiceTopic,
                "DDS.DomainParticipant.CreateTopic (NameService)");

            /* Adapt the default PublisherQos to write into the
               "ChatRoom" Partition. */
            status = participant.GetDefaultPublisherQos(ref pubQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.GetDefaultPublisherQos");
            pubQos.Partition.Name = new string[1];
            pubQos.Partition.Name[0] = partitionName;

            /* Create a Publisher for the chatter application. */
            IPublisher chatPublisher = participant.CreatePublisher(pubQos);
            ErrorHandler.checkHandle(
                chatPublisher, "DDS.DomainParticipant.CreatePublisher");

            /* Create a DataWriter for the ChatMessage Topic
               (using the appropriate QoS). */
            chatPublisher.GetDefaultDataWriterQos(ref dwQos);
            status = chatPublisher.CopyFromTopicQos(ref dwQos, reliableTopicQos);
            ErrorHandler.checkStatus(status, "DDS.Publisher.CopyFromTopicQos");

            IDataWriter parentWriter = chatPublisher.CreateDataWriter(chatMessageTopic, dwQos);
            ErrorHandler.checkHandle(
                parentWriter, "DDS.Publisher.CreateDatawriter (chatMessage)");

            /* Narrow the abstract parent into its typed representative. */
            ChatMessageDataWriter talker = parentWriter as ChatMessageDataWriter;
            ErrorHandler.checkHandle(
                talker, "Chat.ChatMessageDataWriter");

            /* Create a DataWriter for the NameService Topic
               (using the appropriate QoS). */
            status = chatPublisher.GetDefaultDataWriterQos(ref nsDwQos);
            ErrorHandler.checkStatus(
                status, "DDS.Publisher.GetDefaultDatawriterQos");
            status = chatPublisher.CopyFromTopicQos(ref nsDwQos, settingTopicQos);
            ErrorHandler.checkStatus(status, "DDS.Publisher.CopyFromTopicQos");

            WriterDataLifecycleQosPolicy writerDataLifecycle = nsDwQos.WriterDataLifecycle;
            writerDataLifecycle.AutodisposeUnregisteredInstances = false;
            IDataWriter nsParentWriter = chatPublisher.CreateDataWriter(nameServiceTopic, nsDwQos);
            ErrorHandler.checkHandle(
                nsParentWriter, "DDS.Publisher.CreateDatawriter (NameService)");

            /* Narrow the abstract parent into its typed representative. */
            NameServiceDataWriter nameServer = nsParentWriter as NameServiceDataWriter;
            ErrorHandler.checkHandle(
                nameServer, "Chat.NameServiceDataWriterHelper");

            /* Initialize the NameServer attributes. */
            NameService ns = new NameService();
            ns.userID = ownID;
            if (chatterName != null)
            {
                ns.name = chatterName;
            }
            else
            {
                ns.name = "Chatter " + ownID;
            }

            /* Write the user-information into the system
               (registering the instance implicitly). */
            status = nameServer.Write(ns);
            ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

            /* Initialize the chat messages. */
            ChatMessage msg = new ChatMessage();
            msg.userID = ownID;
            msg.index = 0;
            if (ownID == TERMINATION_MESSAGE)
            {
                msg.content = "Termination message.";
            }
            else
            {
                msg.content = "Hi there, I will send you " +
                    NUM_MSG + " more messages.";
            }
            System.Console.WriteLine("Writing message: \"" + msg.content + "\"");

            /* Register a chat message for this user
               (pre-allocating resources for it!!) */
            InstanceHandle userHandle = talker.RegisterInstance(msg);

            /* Write a message using the pre-generated instance handle. */
            status = talker.Write(msg, userHandle);
            ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

            Thread.Sleep(1000);

            /* Write any number of messages . */
            for (int i = 1; i <= NUM_MSG && ownID != TERMINATION_MESSAGE; i++)
            {
                msg.index = i;
                msg.content = "Message no. " + i;
                Console.WriteLine("Writing message: \"" + msg.content + "\"");
                status = talker.Write(msg, userHandle);
                ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

                Thread.Sleep(1000); /* do not run so fast! */
            }

            /* Leave the room by disposing and unregistering the message instance */
            status = talker.Dispose(msg, userHandle);
            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageDataWriter.Dispose");
            status = talker.UnregisterInstance(msg, userHandle);
            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageDataWriter.unregister_instance");

            /* Also unregister our name. */
            status = nameServer.UnregisterInstance(ns, InstanceHandle.Nil);
            ErrorHandler.checkStatus(
                status, "Chat.NameServiceDataWriter.unregister_instance");

            /* Remove the DataWriters */
            status = chatPublisher.DeleteDataWriter(talker);
            ErrorHandler.checkStatus(
                status, "DDS.Publisher.DeleteDatawriter (talker)");

            status = chatPublisher.DeleteDataWriter(nameServer);
            ErrorHandler.checkStatus(status,
                "DDS.Publisher.DeleteDatawriter (nameServer)");

            /* Remove the Publisher. */
            status = participant.DeletePublisher(chatPublisher);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeletePublisher");

            /* Remove the Topics. */
            status = participant.DeleteTopic(nameServiceTopic);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeleteTopic (nameServiceTopic)");

            status = participant.DeleteTopic(chatMessageTopic);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeleteTopic (chatMessageTopic)");

            /* Remove the DomainParticipant. */
            status = dpf.DeleteParticipant(participant);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipantFactory.DeleteParticipant");

        }
Пример #36
0
 void ParseParameters(IDnlibDef def, ConfuserContext context, NameService service, ProtectionParameters parameters)
 {
     var mode = parameters.GetParameter<RenameMode?>(context, def, "mode", null);
     if (mode != null)
         service.SetRenameMode(def, mode.Value);
 }
Пример #37
0
        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt)
        {
            if (evt.DeclaringType.IsVisibleOutside() &&
                !IsVisibleOutside(context, parameters, evt))
                service.SetCanRename(evt, false);

            else if (evt.IsRuntimeSpecialName)
                service.SetCanRename(evt, false);
        }
Пример #38
0
        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property)
        {
            if (property.DeclaringType.IsVisibleOutside() &&
                !IsVisibleOutside(context, parameters, property))
                service.SetCanRename(property, false);

            else if (property.IsRuntimeSpecialName)
                service.SetCanRename(property, false);

            else if (parameters.GetParameter(context, property, "forceRen", false))
                return;

            else if (property.DeclaringType.Implements("System.ComponentModel.INotifyPropertyChanged"))
                service.SetCanRename(property, false);

            else if (property.DeclaringType.Name.String.Contains("AnonymousType"))
                service.SetCanRename(property, false);
        }
Пример #39
0
        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field)
        {
            if (field.DeclaringType.IsVisibleOutside() &&
                (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) &&
                !IsVisibleOutside(context, parameters, field))
                service.SetCanRename(field, false);

            else if (field.IsRuntimeSpecialName)
                service.SetCanRename(field, false);

            else if (parameters.GetParameter(context, field, "forceRen", false))
                return;

            else if (field.DeclaringType.IsSerializable && !field.IsNotSerialized)
                service.SetCanRename(field, false);

            else if (field.IsLiteral && field.DeclaringType.IsEnum)
                service.SetCanRename(field, false);
        }
Пример #40
0
        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method)
        {
            if (method.DeclaringType.IsVisibleOutside() &&
                (method.IsFamily || method.IsFamilyOrAssembly || method.IsPublic) &&
                !IsVisibleOutside(context, parameters, method))
                service.SetCanRename(method, false);

            else if (method.IsRuntimeSpecialName)
                service.SetCanRename(method, false);

            else if (parameters.GetParameter(context, method, "forceRen", false))
                return;

            else if (method.DeclaringType.IsComImport() && !method.HasAttribute("System.Runtime.InteropServices.DispIdAttribute"))
                service.SetCanRename(method, false);

            else if (method.DeclaringType.IsDelegate())
                service.SetCanRename(method, false);
        }
Пример #41
0
        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type)
        {
            if (IsVisibleOutside(context, parameters, type)) {
                service.SetCanRename(type, false);
            }
            else if (type.IsRuntimeSpecialName || type.IsGlobalModuleType) {
                service.SetCanRename(type, false);
            }
            else if (type.FullName == "ConfusedByAttribute") {
                // Courtesy
                service.SetCanRename(type, false);
            }

            if (parameters.GetParameter(context, type, "forceRen", false))
                return;

            if (type.InheritsFromCorlib("System.Attribute")) {
                service.ReduceRenameMode(type, RenameMode.ASCII);
            }

            if (type.InheritsFrom("System.Configuration.SettingsBase")) {
                service.SetCanRename(type, false);
            }
        }
Пример #42
0
        private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field)
        {
            if (field.DeclaringType.IsVisibleOutside() &&
                (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) &&
                !parameters.GetParameter<bool>(context, field, "renPublic", false))
                service.SetCanRename(field, false);

            else if (field.IsRuntimeSpecialName || field.IsSpecialName)
                service.SetCanRename(field, false);
        }
Пример #43
0
        private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt)
        {
            if (evt.DeclaringType.IsVisibleOutside() &&
                !parameters.GetParameter<bool>(context, evt, "renPublic", false))
                service.SetCanRename(evt, false);

            else if (evt.IsRuntimeSpecialName || evt.IsSpecialName)
                service.SetCanRename(evt, false);
        }