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


C# MessageCollection.Add方法代码示例

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


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

示例1: CheckType

		public MessageCollection CheckType(TypeDefinition type, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection();

			foreach (MethodDefinition method in type.Methods)
			{
				if (!method.IsStatic)
				{
					return null;
				}
			}

			foreach (FieldDefinition field in type.Fields)
			{
				if (!field.IsStatic)
				{
					return null;
				}
			}
			
			foreach (MethodDefinition ctor in type.Constructors)
			{
				if (!ctor.IsStatic && (ctor.Attributes & MethodAttributes.Public) == MethodAttributes.Public)
				{
					Location location = new Location(type.Name, ctor.Name, 0);
					Message message = new Message(MessageString, location, MessageType.Error);
					messageCollection.Add(message);
				}
			}

			return messageCollection.Count > 0 ? messageCollection : null;
			
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:33,代码来源:AvoidConstructorsInStaticTypesRule.cs

示例2: CanCreateTransaction

        public void CanCreateTransaction()
        {
            SendPipelineWrapper pipeline =
            PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

             using ( TransactionControl control = pipeline.EnableTransactions() )
             {
            // Create the input message to pass through the pipeline
            Stream stream = DocLoader.LoadStream("SampleDocument.xml");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            // Add the necessary schemas to the pipeline, so that
            // disassembling works
            pipeline.AddDocSpec(typeof(Schema1_NPP));
            pipeline.AddDocSpec(typeof(Schema2_WPP));

            MessageCollection inputMessages = new MessageCollection();
            inputMessages.Add(inputMessage);

            // Execute the pipeline, and check the output
            IBaseMessage outputMessage = pipeline.Execute(inputMessages);

            Assert.IsNotNull(outputMessage);
            control.SetComplete();
             }
        }
开发者ID:vintem,项目名称:pipelinetesting,代码行数:26,代码来源:SendPipelineTests.cs

示例3: CheckMethod

		public MessageCollection CheckMethod(MethodDefinition method, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection();

			if (method.Body == null || method.Body.Instructions == null)
			{
				return null;
			}

			foreach (Instruction instruction in method.Body.Instructions)
			{
				if (instruction.OpCode.Code == Code.Pop)
				{
					Message message = CheckForViolation(instruction.Previous);

					if (message != null)
					{
						messageCollection.Add(message);
					}
				}
			}
			

			return messageCollection.Count == 0 ? runner.RuleSuccess : messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:DontIgnoreMethodResultRule.cs

示例4: CheckType

		public MessageCollection CheckType (TypeDefinition typeDefinition, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			if (InheritsFromAttribute (typeDefinition)) {
				if (!typeDefinition.Name.EndsWith ("Attribute")) {
					Location location = new Location (typeDefinition.FullName, typeDefinition.Name, 0);
					Message message = new Message ("The class name doesn't end with Attribute Suffix", location, MessageType.Error);
					messageCollection.Add (message);                        
				}
			}
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:14,代码来源:AttributeEndsWithAttributeSuffixRule.cs

示例5: CheckType

		public MessageCollection CheckType (TypeDefinition type, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			
			if (!ImplementsInternalsVisibleToAttribute (type) && (type.GetType ().IsAnsiClass || type.GetType ().IsClass || type.GetType ().IsAutoClass) && type.Name != "<Module>" && IsInstantiable (type) && !IsInstantiated (type, type)) {
				Location location = new Location (type.FullName, type.Name, 0);
				Message message = new Message ("There is no call for any of the types constructor found", location, MessageType.Error);
				messageCollection.Add (message);
			}
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:14,代码来源:AvoidUninstantiatedInternalClassesRule.cs

示例6: GlobalMessages

        public MessageCollection GlobalMessages()
        {
            MessageCollection messageCollection = new MessageCollection();

            lock(lockObject)
            {
                foreach(Message message in globalMessages)
                {
                    messageCollection.Add(message);
                }
            }

            return(messageCollection);
        }
开发者ID:ewcasas,项目名称:DVTK,代码行数:14,代码来源:DataWarehouse.cs

示例7: ValidatePhone

 /// <summary>
 /// ensures that phone number has at least 10 digits
 /// </summary>
 public static bool ValidatePhone(string p_phoneNumber, MessageCollection p_errors, string p_message, bool p_isRequired = false)
 {
     if (string.IsNullOrEmpty(p_phoneNumber)) {
         if (p_isRequired) {
             p_errors.Add(p_message);
             return false;
         }
         return true;
     }
     if (Helpers.ValidateLength(p_phoneNumber, p_errors, p_message, 10, 50, p_isRequired)) {
         var phoneNumber = Regex.Replace(p_phoneNumber, "[^0-9]", "");
         return Helpers.ValidateLength(phoneNumber, p_errors, p_message, 10, 50, p_isRequired);
     }
     return false;
 }
开发者ID:shawnewallace,项目名称:Griz,代码行数:18,代码来源:ValidationHelpers.cs

示例8: CheckMethod

		public MessageCollection CheckMethod (MethodDefinition method, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			TypeDefinition type = method.DeclaringType as TypeDefinition;
			
			if (MemberIsCallable (type, method) && !MemberIsCalled (type, method)) {
				Location location = new Location (method.DeclaringType.FullName, method.Name, 0);
				Message message = new Message ("The private or internal code is not called", location, MessageType.Error);
				messageCollection.Add (message);
			}
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:15,代码来源:AvoidUncalledPrivateCodeRule.cs

示例9: CheckType

		public MessageCollection CheckType (TypeDefinition type, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			if (!ImplementsICloneable (type))
				foreach (MethodDefinition method in type.Methods)
					if (method.Name == "Clone" && method.ReturnType.ReturnType.ToString ().Equals ("System.Object") && method.Parameters.Count == 0) {
						Location location = new Location (type.FullName, type.Name, 0);
						Message message = new Message ("The Clone () method is used, but ICloneable is not implemented", location, MessageType.Error);
						messageCollection.Add (message);
					}
					    
			if (messageCollection.Count == 0)
					return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:15,代码来源:UsingCloneWithoutImplementingICloneableRule.cs

示例10: CheckType

		public MessageCollection CheckType (TypeDefinition typeDefinition, Runner runner) 
		{
			messageCollection = new MessageCollection ();
			CodeDuplicatedLocator codeDuplicatedLocator = new CodeDuplicatedLocator ();
			foreach (MethodDefinition currentMethod in typeDefinition.Methods) {
				foreach (Message message in codeDuplicatedLocator.CompareMethodAgainstTypeMethods (currentMethod, typeDefinition)) {
					messageCollection.Add (message);
				}
				codeDuplicatedLocator.CheckedMethods.Add (currentMethod.Name);
			}
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:15,代码来源:AvoidCodeDuplicatedInSameClassRule.cs

示例11: CheckType

		public MessageCollection CheckType (TypeDefinition type, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			EqualsOrGetHashCode (type);
			
			if (equals == true && getHashCode == false)
			{
				Location location = new Location (type.FullName, type.Name, 0);
				Message message = new Message ("Implements Object.Equals (Object) but does not implement Object.GetHashCode ()", location, MessageType.Error);
				messageCollection.Add (message);
			}
			else if (equals == false && getHashCode == true)
			{
				Location location = new Location (type.FullName, type.Name, 0);
				Message message = new Message ("Implements Object.GetHashCode () but does not implement Object.Equals (Object)", location, MessageType.Error);
				messageCollection.Add (message);
			}
			else
				return runner.RuleSuccess;
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:24,代码来源:ImplementingEqualsButNotGetHashCodeAndViceVersaRule.cs

示例12: CheckType

		public MessageCollection CheckType (TypeDefinition typeDefinition, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			if (typeDefinition.IsEnum) {
				if (!HasFlagsAttribute (typeDefinition)) {
					if (IsPlural (typeDefinition.Name)) {
						Location location = new Location (typeDefinition.FullName, typeDefinition.Name, 0);
						Message message = new Message ("The enum has a plural name.", location, MessageType.Error);
						messageCollection.Add (message);
					}
				}
			}
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:16,代码来源:UseSingularNameInEnumsUnlessAreFlagsRule.cs

示例13: CheckType

		public MessageCollection CheckType (TypeDefinition type, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			if (type.IsSealed) {
				foreach (FieldDefinition field in type.Fields) {
					if (field.Attributes.ToString () == "Family") {
						Location location = new Location (type.FullName, type.Name, 0);
						Message message = new Message ("This sealed class contains protected field(s)", location, MessageType.Error);
						messageCollection.Add (message);
					}
				}
			}
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:16,代码来源:DontDeclareProtectedFieldsInSealedClassRule.cs

示例14: Main

        static void Main(string[] args)
        {
            if (args.Length < 2) {
                Console.WriteLine("Android SMS HTMLifer");
                Console.WriteLine("Usage: android-sms-htmlifier.exe name filename");
                Console.WriteLine();
                return;
            }

            string ownerName = args[0];
            string xmlPath = args[1];
            string htmlPath = Path.ChangeExtension(xmlPath, ".html");

            MessageCollection msgCollection = new MessageCollection();
            Array.ForEach(Sms.FromXmlFile(xmlPath, ownerName), x => msgCollection.Add(x));
            msgCollection.OutputHtml(htmlPath);
        }
开发者ID:IntelOrca,项目名称:android-sms-htmlifier,代码行数:17,代码来源:Program.cs

示例15: CheckMethod

		public MessageCollection CheckMethod (MethodDefinition method, Runner runner)
		{
			MessageCollection messageCollection = new MessageCollection ();
			
			if (method.HasBody && method.Name == "Equals" && method.ReturnType.ReturnType.ToString () == "System.Boolean" && method.IsVirtual && !method.IsNewSlot)
				foreach (ParameterDefinition param in method.Parameters)
					if (param.ParameterType.FullName == "System.Object")
						if (!HandlesNullArg (method)) {
						Location location = new Location (method.DeclaringType.FullName, method.Name, 0);
						Message message = new Message ("The overridden method Object.Equals (Object) does not return false if null value is found", location, MessageType.Error);
						messageCollection.Add (message);
					}
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:17,代码来源:EqualShouldHandleNullArgRule.cs


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