예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var query = ProductDataManage.Instance.GetLambdaQuery();

            query.Select(b => new { b.InterFaceUser, b.ProductName, b.PurchasePrice });//选择查询的字段
            int?   n2 = 10;
            classA a  = new classA()
            {
                Name = "ffffff"
            };

            query.Top(100);               //取多少条
            query.Where(b => b.Id < 700); //查询条件
            query.Where(b => b.ProductName.Contains("w2") || b.ProductName.Contains("sss"));
            string s = "ssss";
            int    n = 10;

            query.Where(b => b.ProductName == s && b.Id > n || b.ProductName.Contains("sss"));
            query.Where(b => b.Id == n2.Value);
            query.Where(b => b.ProductName == a.Name);
            query.Where(b => b.ProductName == a.Method());
            query.Where(b => b.ProductName.Contains("sss"));
            query.OrderBy(b => b.Id, true);      //排序条件
            query.OrderBy(b => b.Number, false); //多列排序调用多次
            txtOutput.Visible = true;
            txtOutput.Text    = query.PrintQuery();

            var list = query.ToList();

            Response.Write(string.Format("解析语法用时:{0}ms 数据查询用时:{1}ms 对象映射用时:{2}ms {3}行", query.AnalyticalTime, query.ExecuteTime, query.MapingTime, list.Count));
        }
예제 #2
0
파일: Query2.aspx.cs 프로젝트: yhhno/CRL3
        protected void Button1_Click(object sender, EventArgs e)
        {
            var query = Code.ProductDataManage.Instance.GetLambdaQuery();
            query.Select(b => new { b.InterFaceUser, b.ProductName, b.PurchasePrice });//选择查询的字段
            int? n2 = 10;
            classA a = new classA() { Name = "ffffff" };
            query.Top(100);//取多少条
            query.Where(b => b.Id < 700);//查询条件
            query.Where(b => b.ProductName.Contains("w2") || b.ProductName.Contains("sss"));
            string s = "ssss";
            int n = 10;

            query.Where(b => b.ProductName == s && b.Id > n || b.ProductName.Contains("sss"));
            query.Where(b => b.Id == n2.Value);
            query.Where(b => b.ProductName == a.Name);
            query.Where(b => b.ProductName == a.Method());
            query.Where(b => b.ProductName.Contains("sss"));
            query.OrderBy(b => b.Id, true);//排序条件
            query.OrderBy(b => b.Number, false);//多列排序调用多次
            txtOutput.Visible = true;
            txtOutput.Text = query.PrintQuery();

            var list = query.ToList();
            Response.Write(string.Format("解析语法用时:{0}ms 数据查询用时:{1}ms 对象映射用时:{2}ms {3}行", query.AnalyticalTime, query.ExecuteTime, query.MapingTime, list.Count));
        }
예제 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var query = Code.ProductDataManage.Instance.GetLamadaQuery();

            query = query.Select(b => new { b.InterFaceUser, b.ProductName, b.PurchasePrice });//选择查询的字段
            int?n2 = 10;

            query = query.Top(10);                                              //取多少条
            query = query.Where(b => b.Id < 700 && b.InterFaceUser == "USER1"); //查询条件
            query.Where(b => b.ProductName.Contains("w2") || b.ProductName.Contains("sss"));
            string s = "ssss";
            int    n = 10;
            classA a = new classA()
            {
                Name = "ffffff"
            };

            query.Where(b => b.ProductName == s && b.Id > n || b.ProductName.Contains("sss"));
            query.Where(b => b.Id == n2.Value);
            query.Where(b => b.ProductName == a.Name);
            query.Where(b => b.ProductName == a.Method());
            query.Where(b => b.ProductName.Contains("sss"));
            query = query.OrderBy(b => b.Id, true);//排序条件
            var list = Code.ProductDataManage.Instance.QueryList(query);
        }
예제 #4
0
 public void deserialize(classA a)
 {
     a.transform.position = new Vector3(position[0], position[1], position[2]);
     a.myList             = list;
     //a.aType = type;
     //a.dic = dic;
     a.newData = newd;
 }
예제 #5
0
 public void Dispose()
 {
     if (cA != null)
     {
         cA.Dispose();
         cA = null;
     }
 }
 public void test()
 {
     if (Property1 == null)
     {
         Property1 = new classA();
     }
     Property1.age = 24;
 }
예제 #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //============ 1. 基本覆寫ToString() 格式化 + IFormattable 格式化(可帶參數的字串格式化)
            classA      objA = new classA();
            classPerson objB = new classPerson()
            {
                IDCode = "H333456789", FirstName = "王", LastName = "小明"
            };

            //Class資訊(類別資訊)
            var resultA = objA.ToString();
            //王 小明
            var resultB = objB.ToString("Ch", null);
            //小明 王
            var resullC = objB.ToString("Eg", null);
            //王 小明
            var resullD = objB.ToString();


            //============= 2. 使用格式化器的方法

            classPerson objC = new classPerson()
            {
                FirstName = "王", LastName = "大明", IDCode = "H333456790"
            };
            classPersonFormatter cpFormatter = new classPersonFormatter();
            //王 大明
            var result_objC_A = objC.ToString();
            //王 大明
            var result_objC_B = cpFormatter.Format("Ch", objC, null);
            //大明 王
            var resull_objC_C = cpFormatter.Format("Eg", objC, null);
            //王 大明 : H333456790
            var resull_objC_D = cpFormatter.Format("ChM", objC, null);

            //============  結合 1. 2.的方法
            classPersonCombination objD =
                new classPersonCombination()
            {
                FirstName = "王", LastName = "超明", IDCode = "H333456791"
            };

            classPersonFormatter cp2Formatter = new classPersonFormatter();
            //王 超明
            var result_objD_A = objD.ToString();
            //王 超明
            var result_objD_B = objD.ToString("Ch", cp2Formatter);
            //超明 王
            var resull_objD_C = objD.ToString("Eg", cp2Formatter);
            //王 超明 : H333456791
            var resull_objD_D = objD.ToString("ChM", cp2Formatter);
        }
예제 #8
0
        static void Main(string[] args)
        {
            classB b = new classB();
            classA a = null;

            if (b is classA)
            {
                a = (classA)b;
            }
            else
            {
                a = null;
            }

            a = b as classA;
        }
예제 #9
0
        public SerializedClassA(classA a)
        {
            position    = new float[3];
            position[0] = a.transform.position.x;
            position[1] = a.transform.position.y;
            position[2] = a.transform.position.z;


            list = new List <int>(a.myList);

            //dic = a.dic;

            //type = a.aType;

            newd = a.newData;
        }
예제 #10
0
        static void Main(string[] args)
        {
            Car car1 = new Car();

            classA clA = new classA();
            classB clB = new classB();
            classC clC = new classC();

            WriteLine(clC);
            classD          clD = new classD();
            classF          clF = new classF();
            classE          clE = new classE();
            Company::ClassX clX = new Company::ClassX(); // to solve conflict!
            int             a   = (int)Sqrt(8899);

            WriteLine(a);
            Console.ReadKey();
        }
예제 #11
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     var query = Code.ProductDataManage.Instance.GetLamadaQuery();
     query = query.Select(b => new { b.InterFaceUser, b.ProductName, b.PurchasePrice });//选择查询的字段
     int? n2 = 10;
     query = query.Top(10);//取多少条
     query = query.Where(b => b.Id < 700 && b.InterFaceUser == "USER1");//查询条件
     query.Where(b => b.ProductName.Contains("w2") || b.ProductName.Contains("sss"));
     string s="ssss";
     int n = 10;
     classA a = new classA() { Name = "ffffff" };
     query.Where(b => b.ProductName == s && b.Id > n || b.ProductName.Contains("sss"));
     query.Where(b => b.Id == n2.Value);
     query.Where(b => b.ProductName == a.Name);
     query.Where(b => b.ProductName == a.Method());
     query.Where(b=>b.ProductName.Contains("sss"));
     query = query.OrderBy(b => b.Id, true);//排序条件
     var list = Code.ProductDataManage.Instance.QueryList(query);
 }
예제 #12
0
    // Start is called before the first frame update
    void Start()
    {
        classA classAInst = new classA()
        {
            aInt = 1, bFloat = 2.0f, cDouble = 2383.5
        };
        classB classBInst = new classB()
        {
            strString = "你好!"
        };
        classC classCInst = new classC()
        {
            aClass = classAInst, bClass = classBInst, Vector2C = new Vector2(5, 6), vector3D = new Vector3(7, 8, 9f)
        };
        string jsonClassC = JsonMapper.ToJson(classCInst);

        Debug.LogError($"序列化 jsonClassC:{jsonClassC}");
        classC classUnSeri = JsonMapper.ToObject <classC>(jsonClassC);

        Debug.LogError($"反序列化 classC classUnSeri.vector3D:{classUnSeri.vector3D}");
    }
예제 #13
0
    Dictionary <string, classA> m_dicclassA; //std::map
    // Use this for initialization
    void Start()
    {
        //MonoBehaviour로 부터 상속받은 멤버들.
        //컴포넌트나 게임오브젝트 정보등을 가지고 있다.
        this.transform.position = new Vector3(0, 0, 0);

        //구조체는 정적할당됨.
        m_sStruct = new StructA(200);//생성자함수호출
        //m_sStruct.Data = 10;//set사용
        SetDataStruct(m_sStruct, 20);
        Debug.Log("StructData:" + m_sStruct.Data); //get사용
        m_cClass = new classA(100);                //인스턴스(동적할당)
        //생성된 인스턴스는 가비지컬렉션에 의해 관리되므로 해제할 필요가 없다
        //m_cClass.Data = 20;
        SetDataClass(m_cClass, 10);
        Debug.Log("ClassData:" + m_cClass.Data);
        string addplus   = "A" + "d" + "d";                           //더하기를 하여 문자열을 생성
        string addformat = string.Format("{0}{1}{2}", "A", "d", "d"); //포맷함수를 이용하여 문자열생성

        //문자열을 합칠때는 이러한형식을 쓰는것이 오버헤드가 적다.
        Debug.Log(string.Format("{0}/{1}", addplus, addformat));
    }
예제 #14
0
        static void Main(string[] args)
        {   //difference between overridin and hiding?

            //implicit vs explicit implementation of interface memebers
            MyClass7 obj7 = new MyClass7();
            obj7.InterfaceKill(); //implicitely defined but cant access function implementMeh
            obj7.whatever();//method declared and define in class
            IMyInterface1 myInt = obj7;
            myInt.InterfaceKill();
            myInt.explicitelyImplementMehPls(); //Now we can call it!!!
            //myInt.whatever(); interface code cant access this

            MyBaseClass zuluHide = new derievedClass1(); //Hiding base class implementation
            MyBaseClass zuluOverride = new derievedClass2(); //Overriding

            Console.WriteLine($"Hiding: {zuluHide.add(2, 5)}"); //Ran base class method, not polymorphic
            Console.WriteLine($"Hiding: {zuluOverride.add(2, 5)}"); //called polymorphic overriden method

            classA A = new classA();
            Console.WriteLine($"{A.State}");
            classA.classB B = new classA.classB();
            B.SetPrivateState(A, 999);  //This brings up another point however, how were we able to change the
            //object if it was pass by value and not pass by reference?
            Console.WriteLine($"{A.State}");
            ReadKey();
            //Answer:
            /*
             Since classA is a class (which are reference objects), 
             you can change the contents inside A without passing it as a ref. 
             However, if you pass A as a ref, SetPrivateState can change what the original 
             A refers to. i.e. make it point to a different object.
            
            A reference type is type which has as its value a reference to the appropriate data
            rathar than the data itself
            StringBuilder sb = new StringBuilder();
            sb, create a new string builder object, and assign sb as a reference to the object
            class, interface,delegate, array types are all reference types
            structs and enums are value types
            While reference types have layer of indirection between variable and real data,
            value type dont. variables of value type directly contain data.
            4 types of parameters in functions, default which is value, 
            reference ref, output out, and parameter arrays(params)
            You can use any of them with both value and reference types!
            By default parameter value type, new storage location created
            for the variable in the function member declaration and it starts off
            with the value that you specify in the function member invocation.
  ////////////////////////////////////
          void Foo (StringBuilder x){
                x = null;
            }

            StringBuilder y = new StringBuilder();
            y.Append("hello");
            Foo(y);
            Console.WriteLine(y == null); //This is false because x is a copy of what y refers  but now x refers to null
            //if x was a ref parameter, then this would be true because they 
            dont pass the values of variables, they use the variables themselves
            //The same storage locaiton is used rather than creating a new storage location

/////////////////////////////////////////////////
            void Foo (StringBuilder x){
                x.Append(" world");
            }

            StringBuilder y = new StringBuilder();
            y.Append("hello");
            Foo(y);
            //When you pass y which is a class so reference type, do not think of this as
            object being passed by reference, but object reference passed by value
            Console.WriteLine(y); //returns "hello world", 
            //if y was value type, y would remain "hello" unless it was a ref parameter,
           //then even if y was value type it would be "hello world"

            Output parameters are very similar to reference parameters. The only differences are:
            The parameter must be assigned a value before the function member completes normally.

            /////////////////////////////////////////////////
 
             */

            //System.Object members
            //all objects have a ToString() method which is a method defined in System.Object and which
            //derieved classes can override to output something else. By default, ToString() method 
            //returns class name of the object as a string qualified by any relevant namespaces. 
            //Object Methods:
            //Object() => Constructor
            //~Object() => Destructor
            //static virtual bool Equals(object,object) => checks whther the object paramter refers to the same object
            //override for real check of states
            //static bool ReferenceEquals(object,object) ==> checks whther they are references to the same instnace
            //virtual string ToString() overide pls
            //object MemberwiseClone() ==> protected method can only be used used from within the class or derieved classes
            //member copies references which lead to references to samee objects
            //System.Type GetType() //returns type in form of System.Type object
            //virtual int GetHashCode() //Used as a hash function for objects where this is required. A hash function
            //returns a value identifying the object state in some compressed form.
            Stopwatch watch = new Stopwatch();
            watch.Start();

            //Using typoof and getType =>
            object fun = new MyClass3();
            if (fun.GetType() == typeof(MyClass3))
            {
                Console.WriteLine("They are the same");
            }

            MyClass myObj = new MyClass();
            for (int i = -1; i <= 0; i++)
            {
                try
                {
                    myObj.MyIntProperty = i;
                }
                catch (Exception e)
                {

                    WriteLine($"Exception {e.GetType().FullName} thrown.");
                    WriteLine($"Message: \n\"{e.Message}\"");
                }

            }


            MyClass3 obj3 = new MyClass3();
            obj3.MyIntProp = 5;
            Console.WriteLine($"Automatic Properties are kwel {obj3.MyIntProp}");

            //Classes are reference types and structs are value types
            MyyClass objectA = new MyyClass();
            MyyClass objectB = objectA;//When you assign an object to var, you are actually assigning var with a pointer to which the object refers
            objectA.val = 10;
            objectB.val = 20;
            MyyStruct structA = new MyyStruct();
            MyyStruct structB = structA;//Copying all the information from one struct to another
            structA.val = 10;
            structB.val = 20;

            WriteLine($"objectA val: {objectA.val}");
            WriteLine($"objectB val: {objectB.val}");
            WriteLine($"structA val: {structA.val}");
            WriteLine($"structB val: {structB.val}");

            //TO implement deep copying use interface ICloneable and define function Clone() which returns System.Object


            orientation direction = orientation.North;

            bool success = false;
            do
            {
                try
                {
                    WriteLine("What direction do you want to go (1,2,3,4)");
                    string input = ReadLine();
                    byte number = Convert.ToByte(input);
                    if (number < 0 || number > 4)
                    {
                        throw new System.Exception();
                    }
                    direction = checked((orientation)number);
                    success = true;
                }
                catch (System.InvalidCastException e)
                {
                    WriteLine("Please try again");
                }
                catch (System.FormatException e)
                {
                    WriteLine("Please try again");
                }
                catch
                {
                    WriteLine("Please Try AGGAIN");
                }
            } while (success == false);

            WriteLine("Direction is {0}", direction);




            foreach (string eType in eTypes)
            {
                try
                {
                    WriteLine("Main() try block reached.");        // Line 21
                    WriteLine($"ThrowException(\"{eType}\") called.");
                    ThrowException(eType);
                    WriteLine("Main() try block continues.");      // Line 24
                }
                catch (System.IndexOutOfRangeException e) when (eType == "filter")            // Line 26
                {
                    BackgroundColor = ConsoleColor.Red;
                    WriteLine($"Main() FILTERED System.IndexOutOfRangeException catch block reached. Message:\n\"{e.Message}\"");
                    ResetColor();
                }
                catch (System.IndexOutOfRangeException e)              // Line 32
                {
                    WriteLine($"Main() System.IndexOutOfRangeException catch block reached. Message:\n\"{e.Message}\"");
                }
                catch                                                    // Line 36
                {
                    WriteLine("Main() general catch block reached.");
                }
                finally
                {
                    WriteLine("Main() finally block reached.");
                }
                WriteLine();
            }

            ReadKey();
            watch.Stop();
            WriteLine($"You spent this time on program: {watch.Elapsed}");

        }
예제 #15
0
    public void MethodA(object objClassA)
    {
        classA cls = (classA)objClassA;

        cls.DoSomething();
    }
예제 #16
0
 public B()
 {
     cA = new classA();
 }
예제 #17
0
 protected void foo(int len, ref classA obj)
 {
 }
예제 #18
0
 private void Awake()
 {
     instance = this;
 }
 public classB()
 {
     Property1 = new classA();
 }
예제 #20
0
 void SetDataClass(classA s, int data)
 {
     s.Data = data;
 }
예제 #21
0
 public void test()
 {
     Property1     = new classA();
     Property1.age = 24;
 }
예제 #22
0
 public void SetPrivateState(classA target, int newState)
 {
     target.state = newState;
 }
 public Wrapper(classA obj)
 {
     _wrapped = obj;
 }