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


C# Reflector类代码示例

本文整理汇总了C#中Reflector的典型用法代码示例。如果您正苦于以下问题:C# Reflector类的具体用法?C# Reflector怎么用?C# Reflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Run

        public override object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
        {
            if (parameters == null || (parameters.Length < 2 || parameters.Length > 3))
                throw new ImpressionInterpretException("Filter " + Keyword + " expects 2 or 3 parameters.", markup);

            // text field to bind to
            // selected value

            // text field to bind to
            // value field to bind to
            // selected value

            if (obj == null)
                return null;

            if (obj.GetType().GetInterface("IEnumerable") != null) {

                IReflector reflector = new Reflector();

                bool textOnly = parameters.Length == 2;
                string textField = parameters[0];
                string selectedField = textOnly ? parameters[1] : parameters[2];

                StringBuilder optionBuilder = new StringBuilder();
                IEnumerator en = ((IEnumerable) obj).GetEnumerator();

                // &#34; for quotes
                // &#39; for apostrophes

                // lookup the selected value
                object selectedObject = bag == null ? null : reflector.Eval(bag, selectedField);
                string selectedValue = selectedObject != null ? selectedObject.ToString() : null;

                if (textOnly) {
                    while (en.MoveNext()) {
                        object current = en.Current;
                        object textObject = reflector.Eval(current, textField);
                        string textString = textObject != null ? textObject.ToString() : null;
                        string selected = (textString == selectedValue) ? " selected=\"true\"" : "";
                        optionBuilder.AppendFormat("<option{1}>{0}</option>", textString, selected);
                    }
                } else {
                    string valueField = parameters[1];

                    while(en.MoveNext()) {
                        object current = en.Current;
                        object textObject = reflector.Eval(current, textField);
                        string textString = textObject != null ? textObject.ToString() : null;
                        object valueObject = reflector.Eval(current, valueField);
                        string valueString = valueObject != null ? valueObject.ToString() : null;

                        string selected = (valueString == selectedValue) ? " selected=\"true\"" : "";
                        optionBuilder.AppendFormat("<option value=\"{0}\"{2}>{1}</option>", valueString, textString, selected);
                    }
                }
                return optionBuilder.ToString();
            }

            return null;
        }
开发者ID:codesoda,项目名称:Impression,代码行数:60,代码来源:HtmlOptionsFilter.cs

示例2: Main

        static void Main(string[] args)
        {
            Rotor rL = new Rotor(FixedMechanicRotor.ROTOR_II); 	//II has notch F
            Rotor rM = new Rotor(FixedMechanicRotor.ROTOR_IV);	//IV has notch K
            Rotor rR = new Rotor(FixedMechanicRotor.ROTOR_V);	//V  has notch A

            //Following WW2 Convention, it is Left-Mid-Right e.g. II IV V
            Rotor[] rotors = { rL, rM, rR };

            Reflector re = new Reflector(FixedMechanicReflector.REFLECTOR_B);
            Plugboard plug = new Plugboard(new String[] {
                "AV", "BS", "CG", "DL", "FU", "HZ", "IN", "KM", "OW", "RX"}); //Barbarosa
            WindowSetting initialSetting = new WindowSetting('B', 'L', 'A');
            RingSetting ringPositions = new RingSetting(2, 21, 12);

            //an example of naming hassle because Enigma is both namespace and class
            Enigma.representation.Enigma enigma = new Enigma.representation.Enigma(rotors, re, plug, ringPositions, initialSetting);

            string myfile = "C:\\Users\\ToshiW\\Documents\\Visual Studio 2012\\Projects\\Enigma\\Enigma\\Resources\\BarbarosaCiphertext.txt";
            string input = Utility.FileToString(myfile);
            //Console.WriteLine(readResult);
            //Console.ReadLine();

            //Let Enigma do its thing
            string result = enigma.encryptString(input);

            Console.WriteLine(result);
            Console.ReadLine();
        }
开发者ID:hardyw,项目名称:csharp-enigma,代码行数:29,代码来源:Program.cs

示例3: placeReflector

    private void placeReflector(Vector3 point)
    {
        float x = Mathf.Round(point.x);
        float z = Mathf.Round(point.z);

        switch(reflector)
        {
            case Reflector.BOX:
                placedReflector = Instantiate(reflectorPrefabBox, new Vector3(x, 1, z), Quaternion.identity) as GameObject;
                break;
            case Reflector.NE:
                placedReflector = Instantiate(reflectorPrefabNE, new Vector3(x, 1, z), Quaternion.identity) as GameObject;
                break;
            case Reflector.NW:
                placedReflector = Instantiate(reflectorPrefabNW, new Vector3(x, 1, z), Quaternion.identity) as GameObject;
                break;
            case Reflector.SE:
                placedReflector = Instantiate(reflectorPrefabSE, new Vector3(x, 1, z), Quaternion.identity) as GameObject;
                break;
            case Reflector.SW:
                placedReflector = Instantiate(reflectorPrefabSW, new Vector3(x, 1, z), Quaternion.identity) as GameObject;
                break;
        }

        sound.playSelectSound();
        refGui.blockPlaced = true;
        reflector = Reflector.NONE;
        removePlacedHighlight();
    }
开发者ID:christopherray47,项目名称:LudumDare28,代码行数:29,代码来源:GridMouse.cs

示例4: XmlSerializerOperationBehavior

        public XmlSerializerOperationBehavior(OperationDescription operation, XmlSerializerFormatAttribute attribute)
        {
            if (operation == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
#pragma warning suppress 56506 // Declaring contract cannot be null
            Reflector parentReflector = new Reflector(operation.DeclaringContract.Namespace, operation.DeclaringContract.ContractType);
#pragma warning suppress 56506 // parentReflector cannot be null
            _reflector = parentReflector.ReflectOperation(operation, attribute ?? new XmlSerializerFormatAttribute());
        }
开发者ID:weshaggard,项目名称:wcf,代码行数:9,代码来源:XmlSerializerOperationBehavior.cs

示例5: CreateOutputOptions_should_return_expected_result

        public void CreateOutputOptions_should_return_expected_result()
        {
            var subject = new MapReduceOperation<BsonDocument>(_collectionNamespace, _mapFunction, _reduceFunction, _resultSerializer, _messageEncoderSettings);
            var subjectReflector = new Reflector(subject);
            var expectedResult = new BsonDocument("inline", 1);

            var result = subjectReflector.CreateOutputOptions();

            result.Should().Be(expectedResult);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MapReduceOperationTests.cs

示例6: AddReflection

 public ManualResetEvent AddReflection(Control cntrl)
 {
     if (cntrl == null) return null;
     if (cntrl.IsDisposed) return null;
     if (Exits(cntrl)) return null;
     IScreener cs = new Reflector (cntrl);
     IProjector pj = new Projector(cs, new Reflection(cntrl.Parent.BackColor));
     this.Add(pj);
     return ((Projector)pj).Wait;
 }
开发者ID:kburman,项目名称:Animatrix,代码行数:10,代码来源:Animator.cs

示例7: Awake

    void Awake()
    {
        //bulletLayer = LayerMask.NameToLayer("Bullet");
        enemyLayer = LayerMask.NameToLayer("Enemy");
        hero = this;
        health = _maxHealth = 10;
        stamina = _maxStamina = 200;
        reflector = transform.Find("Reflector").GetComponent<Reflector>();

		rend = GetComponent<Renderer>();
    }
开发者ID:nessenbu2,项目名称:EECS494,代码行数:11,代码来源:Hero.cs

示例8: SteckerbrettM3

 // TODO: Go nuts, make the signal events wire based
 public SteckerbrettM3(Wheel wheel0, Wheel wheel1, Wheel wheel2, Reflector reflector)
 {
     _wheel0 = wheel0;
     _wheel1 = wheel1;
     _wheel2 = wheel2;
     _reflector = reflector;
     HookupWheel0();
     HookupWheel1();
     HookupWheel2();
     HookUpReflector();
 }
开发者ID:c0d3m0nky,项目名称:Enigma,代码行数:12,代码来源:SteckerbrettM3.cs

示例9: constructor_should_initialize_subject

        public void constructor_should_initialize_subject()
        {
            var maxChunkCount = 1;
            var chunkSize = 16;

            var subject = new BsonChunkPool(maxChunkCount, chunkSize);

            var reflector = new Reflector(subject);
            subject.MaxChunkCount.Should().Be(maxChunkCount);
            subject.ChunkSize.Should().Be(chunkSize);
            reflector._disposed.Should().BeFalse();
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonChunkPoolTests.cs

示例10: AddBehaviors

 private static void AddBehaviors(ContractDescription contract, bool builtInOperationBehavior)
 {
     Reflector reflector = new Reflector(contract.Namespace, contract.ContractType);
     foreach (OperationDescription description in contract.Operations)
     {
         System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector reflector2 = reflector.ReflectOperation(description);
         if ((reflector2 != null) && (description.DeclaringContract == contract))
         {
             description.Behaviors.Add(new XmlSerializerOperationBehavior(reflector2, builtInOperationBehavior));
             description.Behaviors.Add(new XmlSerializerOperationGenerator(new XmlSerializerImportOptions()));
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:XmlSerializerOperationBehavior.cs

示例11: EnigmaMachine

 public EnigmaMachine()
 {
     AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver);
     InitializeComponent();
     rotorsToolStripMenuItem_Click(null, null);
     panel6.BackColor = Color.FromArgb(7, 7, 7);
     left_Rotor = new Rotor("I", "EKMFLGDQVZNTOWYHXUSPAIBRCJ", 1, 17);
     mid_Rotor = new Rotor("II", "AJDKSIRUXBLHWTMCQGZNPYFVOE", 1, 5);
     right_Rotor = new Rotor("III", "BDFHJLCPRTXVZNYEIWGAKMUSQO", 1, 22);
     extra_Rotor = new Rotor("IV", "ESOVPZJAYQUIRHXLNFTGKDCMWB", 1, 10);
     reflector = new Reflector("B", "B", "YRUHQSLDPXNGOKMIEBFZCWVJAT");
     DisplayPlugboard();
     Display_Rotors();
 }
开发者ID:jimbojetset,项目名称:EnigmaMachine,代码行数:14,代码来源:EnigmaMachine.cs

示例12: Load

 public void Load(Reflector.CodeModel.IAssembly item)
 {
     try
      {
     //%SystemRoot%\Microsoft.net\Framework\v2.0.50727\mscorlib.dll
     //Engine.Runtime.LoadAssembly(Assembly.LoadFile(Environment.ExpandEnvironmentVariables(item.Location)));
     ThreadStart starter2 = delegate { Engine.Runtime.LoadAssembly(Assembly.LoadFile(Environment.ExpandEnvironmentVariables(item.Location))); };
     new Thread(starter2).Start();
      }
      catch (Exception ex)
      {
     Console.Error.WriteLine("Unable to load assembly: " + item.Location);
      }
 }
开发者ID:BenHall,项目名称:TheMethodist,代码行数:14,代码来源:DLRHost.cs

示例13: CreateOutputOptions_should_return_expected_result

        public void CreateOutputOptions_should_return_expected_result()
        {
            var subject = new MapReduceOutputToCollectionOperation(_collectionNamespace, _outputCollectionNamespace, _mapFunction, _reduceFunction, _messageEncoderSettings);
            var subjectReflector = new Reflector(subject);
            var expectedResult = new BsonDocument
            {
                { "replace", _outputCollectionNamespace.CollectionName },
                { "db", _outputCollectionNamespace.DatabaseNamespace.DatabaseName }
            };

            var result = subjectReflector.CreateOutputOptions();

            result.Should().Be(expectedResult);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:14,代码来源:MapReduceOutputToCollectionOperationTests.cs

示例14: ShowDialog

        public bool ShowDialog(IntPtr hWndOwner)
        {
            bool flag = false;

            if (Environment.OSVersion.Version.Major >= 6)
            {
                var r = new Reflector("System.Windows.Forms");

                uint num = 0;
                Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
                object dialog = r.Call(ofd, "CreateVistaDialog");
                r.Call(ofd, "OnBeforeVistaDialog", dialog);

                uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions");
                options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
                r.CallAs(typeIFileDialog, dialog, "SetOptions", options);

                object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
                object[] parameters = new object[] { pfde, num };
                r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
                num = (uint)parameters[1];

                try
                {
                    int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
                    flag = 0 == num2;
                }
                finally
                {
                    r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
                    GC.KeepAlive(pfde);
                }
            }
            else
            {
                using (var fbd = new FolderBrowserDialog())
                {
                    fbd.Description = this.Title;
                    fbd.SelectedPath = this.InitialDirectory;
                    fbd.ShowNewFolderButton = false;
                    if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) return false;
                    ofd.FileName = fbd.SelectedPath;
                    flag = true;
                }
            }

            return flag;
        }
开发者ID:halalfood,项目名称:WallbaseDownloader,代码行数:48,代码来源:WinDialog.cs

示例15: constructor_should_initialize_subject

        public void constructor_should_initialize_subject()
        {
            var baseSource = Substitute.For<IBsonChunkSource>();
            var maxUnpooledChunkSize = 2;
            var minChunkSize = 4;
            var maxChunkSize = 8;

            var subject = new InputBufferChunkSource(baseSource, maxUnpooledChunkSize, minChunkSize, maxChunkSize);

            var reflector = new Reflector(subject);
            subject.BaseSource.Should().BeSameAs(baseSource);
            subject.MaxChunkSize.Should().Be(maxChunkSize);
            subject.MaxUnpooledChunkSize.Should().Be(maxUnpooledChunkSize);
            subject.MinChunkSize.Should().Be(minChunkSize);
            reflector._disposed.Should().BeFalse();
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:16,代码来源:InputBufferChunkSourceTests.cs


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