} //end method
	
	/// <summary> Checks a code for an exact match, and using certain sequences where some 
	/// characters are wildcards (e.g. HL7nnnn).  If the pattern contains one of 
	/// " or ", " OR ", or "," each operand is checked.
	/// </summary>
	private bool checkCode(System.String code, System.String pattern)
	{
		bool match = false;
		//mod by Neal acharya - Do full match on with the pattern.  If code matches pattern then return true
		//else parse pattern to look for wildcard characters
		if (code.Equals(pattern))
		{
			match = true;
		}
		//end if 
		else
		{
			if (pattern.IndexOf(' ') >= 0 || pattern.IndexOf(',') >= 0)
			{
				SupportClass.Tokenizer tok = new SupportClass.Tokenizer(pattern, ", ", false);
				while (tok.HasMoreTokens() && !match)
				{
					System.String t = tok.NextToken();
					if (!t.ToUpper().Equals("or".ToUpper()))
						match = checkCode(code, t);
				} //end while
			}
			//end if
			else
			{
				if (code.Equals(pattern))
				{
					match = true;
				}
			} //end else
		} //end else 
		return match;
	} //end method
Example #2
0
        //Main_12_2_3
        public static void Main_12_2_3()
        {
            //User user = new User { Name = "小王", Age = 27 };

            var user = new { Name = "小王", Age = 27 };
            var my = new { Name = "Wang", Emal = "Mail@anytao.com" };
            //等效于User v = new User { Name = "小王", Age = 27 };
            Console.WriteLine(user.Name);
            Console.WriteLine(user.GetType());

            var name = "小王";
            var age = 27;
            //等效于string v2 = "123";
            Console.WriteLine(name.GetType());
            Console.WriteLine(age.GetType());

            //创建不同的Type
            var v1 = new { Name = "Aero", Age = 27 };
            var v2 = new { Name = "Emma", Age = 22 };
            var v3 = new { Age = 27, Name = "Aero" };
            Console.WriteLine(v1.Equals(v2));
            Console.WriteLine(v1.Equals(v3));
            Console.WriteLine(ReferenceEquals(v1.GetType(), v2.GetType()));
            Console.WriteLine(ReferenceEquals(v1.GetType(), v3.GetType()));
        }
Example #3
0
    public static void AnonymousTypesMain()
    {
        // create a "person" object using an anonymous type
          var bob = new { Name = "Bob Smith", Age = 37 };

          // display bob's information
          Console.WriteLine( "Bob: " + bob.ToString() );

          // create another "person" object using the same anonymous type
          var steve = new { Name = "Steve Jones", Age = 26 };

          // display steve's information
          Console.WriteLine( "Steve: " + steve.ToString() );

          // determine if objects of the same anonymous type are equal
          Console.WriteLine( "\nBob and Steve are {0}",
         ( bob.Equals( steve ) ? "equal" : "not equal" ) );

          // create a "person" object using an anonymous type
          var bob2 = new { Name = "Bob Smith", Age = 37 };

          // display the bob's information
          Console.WriteLine( "\nBob2: " + bob2.ToString() );

          // determine whether objects of the same anonymous type are equal
          Console.WriteLine( "\nBob and Bob2 are {0}\n",
         ( bob.Equals( bob2 ) ? "equal" : "not equal" ) );
    }
	public virtual FieldSelectorResult Accept(System.String fieldName)
	{
		if (fieldName.Equals(DocHelper.TEXT_FIELD_1_KEY) ||  fieldName.Equals(DocHelper.LAZY_FIELD_BINARY_KEY))
			return FieldSelectorResult.SIZE;
		else if (fieldName.Equals(DocHelper.TEXT_FIELD_3_KEY))
			return FieldSelectorResult.LOAD;
		else
			return FieldSelectorResult.NO_LOAD;
	}
	/// <summary> Empty string, null, and the HL7 explicit null (two double-quotes) are passed.  
	/// 
	/// </summary>
	/// <seealso cref="Genetibase.NuGenHL7.validation.PrimitiveTypeRule.test(java.lang.String)">
	/// </seealso>
	public virtual bool test(System.String value_Renamed)
	{
		if (value_Renamed == null || value_Renamed.Equals("\"\"") || value_Renamed.Equals(""))
		{
			return true;
		}
		else
		{
               return Regex.IsMatch(value_Renamed, matchString);
		}
	}
        /* (non-Javadoc)
        * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
        */
        public virtual bool Accept(System.IO.FileInfo dir, System.String name)
        {
            for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.Length; i++)
            {
                if (name.EndsWith("." + IndexFileNames.INDEX_EXTENSIONS[i]))
                    return true;
            }
            if (name.Equals(IndexFileNames.DELETABLE))
                return true;
            else if (name.Equals(IndexFileNames.SEGMENTS))
                return true;
            else return true; // else if (name.Matches(".+\\.f\\d+")) // {{Aroush-1.9}}

            // return false;
        }
Example #7
0
	public static void IsNull(System.Object argument, string argumentName)
	{
		if (argument == null || argument.Equals(null))
		{
			throw new ArgumentNullException(argumentName);
		}
	}
    public static void Main()
    {
        var myCar = new { Color = "Red", Brand = "BMW", Speed = 180 };
        Console.WriteLine("My car is a {0} {1}.", myCar.Color, myCar.Brand);
        Console.WriteLine("It runs {0} km/h.", myCar.Speed);

        Console.WriteLine();

        var p = new { X = 3, Y = 5 };
        var q = new { X = 3, Y = 5 };
        Console.WriteLine(p);
        Console.WriteLine(q);
        Console.WriteLine(p == q); // false
        Console.WriteLine(p.Equals(q)); // true

        Console.WriteLine();

        var combined = new { P = p, Q = q };
        Console.WriteLine(combined.P.X);

        Console.WriteLine();

        var arr = new[]
                      {
                          new { X = 3, Y = 5 },
                          new { X = 1, Y = 2 },
                          new { X = 0, Y = 7 }
                      };
        foreach (var item in arr)
        {
            Console.WriteLine("({0}, {1})", item.X, item.Y);
        }
    }
Example #9
0
        static void EqualityTest()
        {
            // Make 2 anonymous classes with identical name/value pairs.
            var firstCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
            var secondCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };

            // Are they considered equal when using Equals()?
            if (firstCar.Equals(secondCar))
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");

            // Are they considered equal when using ==?
            if (firstCar == secondCar)
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");

            // Are these objects the same underlying type?
            if (firstCar.GetType().Name == secondCar.GetType().Name)
                Console.WriteLine("We are both the same type!");
            else
                Console.WriteLine("We are different types!");

            // Show all the details.
            Console.WriteLine();
            ReflectOverAnonymousType(firstCar);
            ReflectOverAnonymousType(secondCar);
        }
Example #10
0
        public static void EqualityTest()
        {
            // Make 2 anonymous classes with identical name/value pairs.
            var firstProduct = new { Color = "Blue", Name = "Widget", RetailPrice = 55 };
            var secondProduct = new { Color = "Blue", Name = "Widget", RetailPrice = 55 };

            // Are they considered equal when using Equals()?
            if (firstProduct.Equals(secondProduct))
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");

            // Are they considered equal when using ==?
            if (firstProduct == secondProduct)
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");

            // Are these objects the same underlying type?
            if (firstProduct.GetType().Name == secondProduct.GetType().Name)
                Console.WriteLine("We are both the same type!");
            else
                Console.WriteLine("We are different types!");

            // Show all the details.
            Console.WriteLine();
            ReflectOverAnonymousType(firstProduct);
            ReflectOverAnonymousType(secondProduct);
        }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Anonymous Types *****\n");
            // Make an anonymous type representing a car.
            var myCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
            // Now show the color and make.
            Console.WriteLine("My car is a {0} {1}.", myCar.Color, myCar.Make);
            // Now call our helper method to build anonymous type via args.
            BuildAnonType("BMW", "Black", 90);
            Console.ReadLine();
            ReflectOverAnonymousType(myCar);

            // Make 2 anonymous classes with identical name/value pairs.
            var firstCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
            var secondCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
            // Are they considered equal when using Equals()?
            if (firstCar.Equals(secondCar))
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");
            // Are they considered equal when using ==?
            if (firstCar == secondCar)
                Console.WriteLine("Same anonymous object!");
            else
                Console.WriteLine("Not the same anonymous object!");
            // Are these objects the same underlying type?
            if (firstCar.GetType().Name == secondCar.GetType().Name)
                Console.WriteLine("We are both the same type!");
            else
                Console.WriteLine("We are different types!");
        }
Example #12
0
	/* (non-Javadoc)
	* @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
	*/
	public virtual bool Accept(System.IO.FileInfo dir, System.String name)
	{
		int i = name.LastIndexOf((System.Char) '.');
		if (i != - 1)
		{
			System.String extension = name.Substring(1 + i);
			if (extensions.Contains(extension))
			{
				return true;
			}
			else if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success)
			{
				return true;
			}
			else if (extension.StartsWith("s") && (new System.Text.RegularExpressions.Regex("s\\d+")).Match(extension).Success)
			{
				return true;
			}
		}
		else
		{
			if (name.Equals(IndexFileNames.DELETABLE))
				return true;
			else if (name.StartsWith(IndexFileNames.SEGMENTS))
				return true;
		}
		return false;
	}
Example #13
0
        static void Main(string[] args)
        {
            var firstCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55};
            var SecondCar = new { Color = "Bright Pin", Make = "Saab", CurrentSpeed = 55 };
            // 匿名类型重写的Equals()是基于值类型的实现
            if (firstCar.Equals(SecondCar))
            {
                Console.WriteLine("Equals 是相等的");
            }
            else 
            {
                Console.WriteLine("Equals 是不相等的");
            }
            // 因为匿名对象没有重写C#的相等操作符(==和!=)所以直接比较引用,
            //即这两个引用是不是指向同一个对象
            // 如果重载==和!=  应该调用已经重写了的Equals()
            if (firstCar == SecondCar)
            {
                Console.WriteLine("refer to the same object");
            }
            else 
            {
                Console.WriteLine("Refer to the different object");
            }

            if (firstCar.GetType().Name == SecondCar.GetType().Name) 
            {
                Console.WriteLine("一个类的两个对象");
            }

        }
Example #14
0
        static void Main(string[] args)
        {
            string dada = "the quick brown fox jump over the fence";
            Console.WriteLine(dada.WordCount());
            Console.WriteLine(Eext.WordCount(dada));
            List<int> ints = new List<int> { 1, 2, 4, 6, 2, 6, };

            foreach (var item in ints)
            {
                Console.Write("{0}, ", item);
            }
            ints.IncreaseWith(100);
            Console.WriteLine();
            foreach (var item in ints)
            {
                Console.Write("{0}, ", item);
            }
            Console.WriteLine();

            var point = new { X = 3, Y = 5 };
            var secondPpoint = new { X = 4, Y = 5 };

            Console.WriteLine(point.Equals(secondPpoint));
            Console.WriteLine(point.X);

            Console.WriteLine(point);
            int senek = 12;
            Console.WriteLine(Eext.IncrWithOne(senek));
            Console.WriteLine(senek.IncrWithOne());
        }
Example #15
0
 static void Main(string[] args)
 {
     //定义两个相同的匿名类型
     var Book1 = new { BookName = "ASP.NET 4.0 程序设计", ISBN = "123456789", Price = 59.8 };
     var Book2 = new { BookName = "ASP.NET 4.0 程序设计", ISBN = "123456789", Price = 59.8 };
     //使用重载的Equals方法进行两个匿名类型的等值比较
     if (Book1.Equals(Book2))
     {
         Console.WriteLine("两个匿名类型完全相等!");
     }
     else
     {
         Console.WriteLine("两个匿名类型不相等!");
     }
     //使用C#的==操作符进行两个类型的比较
     if (Book1==Book2)
     {
         Console.WriteLine("两个匿名类型完全相等!");
     }
     else
     {
         Console.WriteLine("两个匿名类型不相等!");
     }
     //查看Book1和Book2这两个匿名类型的内部信息
     GetAnonymousTypesInfo(Book1);
     GetAnonymousTypesInfo(Book2);
 }
Example #16
0
        private static void writeFields(string name, object obj, System.Type c, Dictionary<Ice.Object, object> objectTable,
                                        OutputBase output)
        {
            if(!c.Equals(typeof(object)))
            {
                //
                // Write the superclass first.
                //
                writeFields(name, obj, c.BaseType, objectTable, output);

                //
                // Write the declared fields of the given class.
                //
                FieldInfo[] fields =
                    c.GetFields(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);

                for(int i = 0; i < fields.Length; i++)
                {
                    string fieldName = (name != null ? name + '.' + fields[i].Name : fields[i].Name);

                    try
                    {
                        object val = fields[i].GetValue(obj);
                        writeValue(fieldName, val, objectTable, output);
                    }
                    catch(System.UnauthorizedAccessException)
                    {
                        Debug.Assert(false);
                    }
                }
            }
        }
Example #17
0
 public void Vector_Equals_Test()
 {
     Vector v1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
     Vector v2 = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
     Assert.AreEqual(true, v1.Equals(v2));
     Assert.AreEqual(true, v1 == v2);
 }
Example #18
0
	public virtual FieldSelectorResult Accept(System.String f)
	{
		if (f.Equals(Lucene.Net.Index.TestLazyBug.MAGIC_FIELD))
		{
			return FieldSelectorResult.LOAD;
		}
		return FieldSelectorResult.LAZY_LOAD;
	}
	static int Main ()
	{
		var v1 = new { Name = "Scott", Age = 21 };
		var v2 = new { Age = 20, Name = "Sam" };
		var v3 = new { Name = Null (), Age = 33 };
		
		if (v1.GetType () == v2.GetType ())
			return 1;
			
		if (v1.Equals (v2))
			return 2;
			
		if (v1.GetType () != v3.GetType ())
			return 3;
			
		if (!v1.Equals (v1))
			return 4;
					
		if (v1.GetHashCode () != v1.GetHashCode ())
			return 5;
		
		Console.WriteLine (v1);
		Console.WriteLine (v3);
		
		if (v1.ToString () != "{ Name = Scott, Age = 21 }")
			return 6;
			
		if (v3.ToString () != "{ Name = , Age = 33 }")
			return 7;

		var v4 = new {};

		if (v4.ToString () != "{ }")
			return 8;

		var v5 = new { Foo = "Bar" };
		var v6 = new { Foo = Null () };

		if (v5.ToString () != "{ Foo = Bar }")
			return 9;

		if (v6.ToString () != "{ Foo =  }")
			return 10;

		return 0;
	}
Example #20
0
 public System.String getEffectiveCulture( System.Globalization.CultureInfo ci )
 {
     System.String culture = System.String.Empty;
     if ( !availablecultures.Contains(ci.Name) && !ci.Equals(System.Globalization.CultureInfo.InvariantCulture) )
         culture = this.getEffectiveCulture(ci.Parent);
     else
         culture = ci.Name;
     return culture;
 }
 private bool CertificateValidationCallback(Object sender,
     System.Security.Cryptography.X509Certificates.X509Certificate certificate,
     X509Chain chain,
     SslPolicyErrors sslPolicyErrors)
 {
     Console.WriteLine("Certificate Validation Callback");
     bool result = certificate.Equals(this.sslCertificate);
     Console.WriteLine("TSL Authn result: " + result);
     return result;
 }
Example #22
0
        private System.Object eval(System.Object oLhs, System.Object oRhs)
        {
            if (!(oLhs is System.String))
                return Result.RESULT_UNKNOWN;

            if (!(oRhs is System.String))
                return Result.RESULT_UNKNOWN;

            return (oLhs.Equals(oRhs))?Result.RESULT_TRUE:Result.RESULT_FALSE;
        }
 /// --------------------------------------------------------------------------------
 /// <summary>
 /// Recurses through the lowest order base classes up to the highest order classes loading fields
 /// and hooked objects on each object.
 /// </summary>
 /// --------------------------------------------------------------------------------
 public static void LoadFieldsForBaseTypes(object objObject, System.Type objType, SQL.SQLFieldValues objFields)
 {
     //Skip classes in the DatabaseObjects assembly or class instances of type Object
     //Need to check that the type is not at the object level which can occur when traversing through hooked objects
     if (!objType.Assembly.Equals(System.Reflection.Assembly.GetExecutingAssembly()) && !objType.Equals(typeof(object)))
     {
         LoadFieldsForBaseTypes(objObject, objType.BaseType, objFields);
         LoadFieldsForObject(objObject, objType, objFields);
         LoadFieldsForHookedObjects(objObject, objType, objFields);
         LoadFieldsForObjectReferenceEarlyBinding(objObject, objType, objFields);
     }
 }
Example #24
0
        static void Main(string[] args)
        {
            var employee0 = new { Id = 107, Genre = "Male", Name = "Martin Hroemk" };
            var employee1 = new { Id = 107, Name = "Martin Hroemk", Genre = "Male" };
            var employee2 = new { Id = 369, Name = "Eva Brezovska", Genre = "Female" };

            // anonymni typ je imutable - nemenny
            //employee.Name = "John Rambo";

            Console.WriteLine(employee0.Equals(employee2));
            
        }
Example #25
0
        /// <summary> Returns a subclass of GenericMessage corresponding to a certain version.  
        /// This is needed so that version-specific segments can be added as the message
        /// is parsed.  
        /// </summary>
        public static System.Type getGenericMessageClass(System.String version)
        {
            if (!Parser.validVersion(version))
                throw new System.ArgumentException("The version " + version + " is not recognized");

            System.Type c = null;
            if (version.Equals("2.1"))
            {
                c = typeof(V21);
            }
            else if (version.Equals("2.2"))
            {
                c = typeof(V22);
            }
            else if (version.Equals("2.3"))
            {
                c = typeof(V23);
            }
            else if (version.Equals("2.3.1"))
            {
                c = typeof(V231);
            }
            else if (version.Equals("2.4"))
            {
                c = typeof(V24);
            }
            else if (version.Equals("2.5"))
            {
                c = typeof(V25);
            }
            return c;
        }
Example #26
0
        static void EqualityTest() {
            var car1 = new { Color = "Pink", Make = "Saab", Speed = 55 };
            var car2 = new { Color = "Pink", Make = "Saab", Speed = 55 };

          

            Console.WriteLine("car1.Equals(car2)? {0}", car1.Equals(car2));
            Console.WriteLine("car1 == car2 ? {0}", car1 == car2);
            Console.WriteLine("car1.GetType().Name == car2.GetType().Name ? {0}", car1.GetType().Name == car2.GetType().Name);
            Console.WriteLine();
            ReflectOverAnonymousType(car1);
            ReflectOverAnonymousType(car2);
        }
        public void ShouldntTriggerOnEqualsMethod()
        {
            var hint = new EnumerableOperatorEqualsHint();

            var x = new[] { 3 };
            var y = new[] { 3 };

            Expression<Func<bool>> assertion = () => x.Equals(y);

            string message;
            Assert.IsFalse(hint.TryGetHint(assertion.Body, out message));
            Assert.IsNull(message);
        }
Example #28
0
	public static int Main ()
	{
		var v1 = new {  };
		var v2 = new {  };
		
		if (v1.GetType () != v2.GetType ())
			return 1;
			
		if (!v1.Equals (v2))
			return 2;
			
		Console.WriteLine (v1);
		Console.WriteLine (v2);
		return 0;
	}
 protected override void Activate(System.Transactions.Transaction transaction)
 {
     bool flag = null != transaction;
     OracleConnectionString str = this._connectionOptions;
     if (flag && str.Enlist)
     {
         if (!transaction.Equals(base.EnlistedTransaction))
         {
             this.Enlist(str.UserId, str.Password, str.DataSource, transaction, false);
         }
     }
     else if (!flag && (this._enlistContext != null))
     {
         this.UnEnlist();
     }
 }
Example #30
0
        static void EqualityTest()
        {
            var firstCar = new {Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55};
            var secondCar = new {Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55};
            Console.WriteLine(firstCar.Equals(secondCar) ? "Same anonymous objects!" : "Not the same anonymous objects!");

            Console.WriteLine(firstCar == secondCar ? "Same anonymous objects!" : "Not the same anonymous objects!");

            Console.WriteLine(firstCar.GetType().Name == secondCar.GetType().Name
                    ? "We are both the same type!"
                    : "We are different types!");

            Console.WriteLine();
            ReflectOverAnonymousTypes(firstCar);
            ReflectOverAnonymousTypes(secondCar);
        }