示例#1
0
        public XsMethod DefineMethod(string name, Type returnType)
        {
            var method = CurrentType.DefineMethod(name, returnType, XsParameter.NoParameters);

            MapMethodToCurrentType(method);
            return(method);
        }
示例#2
0
        public XsMethod DefineMethod(string name)
        {
            var method = CurrentType.DefineMethod(name, typeof(void), XsParameter.NoParameters);

            MapMethodToCurrentType(method);
            return(method);
        }
示例#3
0
        public PropertyInstance GetProperty(String propertyName, NewType propertyType)
        {
            PropertyInstance pi = implementedProperties.Get(new PropertyKey(propertyName, propertyType));

            if (pi != null)
            {
                return(pi);
            }
            BindingFlags flags        = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
            PropertyInfo propertyInfo = propertyType != null?CurrentType.GetProperty(propertyName, flags, null, propertyType.Type, Type.EmptyTypes, new ParameterModifier[0]) : CurrentType.GetProperty(propertyName, flags);

            if (propertyInfo != null)
            {
                pi = new PropertyInstance(propertyInfo);
            }
            if (pi == null)
            {
                MethodInfo m_get = CurrentType.GetMethod("Get" + propertyName, flags);
                if (m_get == null)
                {
                    m_get = CurrentType.GetMethod("get" + propertyName, flags);
                }
                MethodInfo m_set = CurrentType.GetMethod("Set" + propertyName, flags);
                if (m_set == null)
                {
                    m_set = CurrentType.GetMethod("set" + propertyName, flags);
                }
                if (m_get != null || m_set != null)
                {
                    pi = new PropertyInstance(propertyName, m_get != null ? new MethodInstance(m_get) : null, m_set != null ? new MethodInstance(m_set) : null);
                }
            }
            return(pi);
        }
示例#4
0
        public async Task <IEnumerable <Produto> > FindByName(Produto user)
        {
            IFindFluent <Produto, Produto> findFluent = CurrentType.Find(c => c.Ativo == true && c.Nome.Contains(user.Nome));
            List <Produto> users = findFluent.ToList();

            return(users);
        }
示例#5
0
        public async Task <string> Auth(Mercado item)
        {
            IFindFluent <Mercado, Mercado> findFluent = CurrentType.Find(c => c.Senha == item.Senha);
            List <Mercado> users = findFluent.ToList();

            return(users.FirstOrDefault().Id);
        }
示例#6
0
        public async Task <IEnumerable <Mercado> > GetAll()
        {
            IFindFluent <Mercado, Mercado> findFluent = CurrentType.Find(c => c.Ativo == true);
            List <Mercado> users = findFluent.ToList();

            return(users);
        }
示例#7
0
        public async Task <string> Auth(Usuario item)
        {
            IFindFluent <Usuario, Usuario> findFluent = CurrentType.Find(c => c.Email == item.Email && c.Senha == item.Senha);
            List <Usuario> users = findFluent.ToList();

            return(users.FirstOrDefault().Id);
        }
示例#8
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            CurrentType currentType = (CurrentType)value;

            return(currentType == CurrentType.AC ? "交流" : "直流");
            //throw new NotImplementedException();
        }
示例#9
0
            private bool FindNextMethod()
            {
                for (;;)
                {
                    CurrentSymbol = (CurrentSymbol == null
                        ? _symbolLoader.LookupAggMember(_name, CurrentType.getAggregate(), _mask)
                        : SymbolLoader.LookupNextSym(CurrentSymbol, CurrentType.getAggregate(), _mask)) as MethodOrPropertySymbol;

                    // If we couldn't find a sym, we look up the type chain and get the next type.
                    if (CurrentSymbol == null)
                    {
                        if (!FindNextTypeForInstanceMethods())
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        // Note that we do not filter the current symbol for the user. They must do that themselves.
                        // This is because for instance, BindGrpToArgs wants to filter on arguments before filtering
                        // on bogosity.

                        // If we're here, we're good to go.

                        return(true);
                    }
                }
            }
示例#10
0
        void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PropertyInfo pi    = CurrentType.GetProperty(displayMemberPath);
            string       value = pi.GetValue((sender as ListBox).SelectedItem, null).ToString();

            this.Txt.Text      = value;
            listBox.Visibility = Visibility.Hidden;
        }
示例#11
0
        public async Task <Mercado> GetById(string id)
        {
            IFindFluent <Mercado, Mercado> findFluent = CurrentType.Find(c => c.Id == id);

            findFluent.Limit(1);
            Mercado mercado = await findFluent.FirstOrDefaultAsync();

            return(mercado);
        }
示例#12
0
        void push(CurrentType type, Object obj)
        {
            Debug.WriteLine("XamlParser: PUSHING: " + oldStates.Count + " " + type);
            ParserState currentState = new ParserState();

            currentState.type = type;
            currentState.obj  = obj;
            oldStates.Add(currentState);
        }
示例#13
0
        public void OnWrongBallCollision()
        {
            _canMove = false;

            var disolveMaterialName = CurrentType.GetDisolveMaterialName();
            var disolveMaterial     = materials.First(x => x.name == disolveMaterialName);

            _meshRenderer.material = disolveMaterial;
            animator.SetTrigger("StartDisolve");
        }
示例#14
0
        public Object GetAlreadyImplementedEvent(String eventName)
        {
            Object eventInfo = implementedEvents.Get(eventName);

            if (eventInfo != null)
            {
                return(eventInfo);
            }
            return(CurrentType.GetEvent(eventName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
        }
示例#15
0
        private object[] GetAttributes(object[] attributes)
        {
            for (index = types.Length - 1; index > 0; index--)
            {
                ProcessType(CurrentType.GetCustomAttributes(false));
            }

            ProcessType(attributes);

            CollectSingletons();
            return(results.ToArray());
        }
 public override void WriteBytes(object obj, Stream stream)
 {
     if (obj == null)
     {
         stream.WriteByte(0);
     }
     else
     {
         stream.WriteByte(1);
         Serialize(TypeArgs[0].MakeArrayType(), CurrentType.GetProperty("Keys").GetValue(obj), stream);
         Serialize(TypeArgs[1].MakeArrayType(), CurrentType.GetProperty("Values").GetValue(obj), stream);
     }
 }
示例#17
0
 internal bool setPower(bool powerIsOn)
 {
     if (powerIsOn && Current == CurrentType.OFF)
     {
         Current = CurrentType.ON;
         return(true);
     }
     else if (!powerIsOn && Current == CurrentType.ON)
     {
         Current = CurrentType.OFF;
         return(true);
     }
     return(false);
 }
 public override void ReadBytes(Stream stream, out object obj)
 {
     obj = null;
     if (stream.ReadByte() != 0)
     {
         var keys   = (Array)Deserialize(TypeArgs[0].MakeArrayType(), stream);
         var values = (Array)Deserialize(TypeArgs[1].MakeArrayType(), stream);
         obj = Activator.CreateInstance(CurrentType);
         MethodInfo Add = CurrentType.GetMethod("Add");
         for (int i = 0; i < keys.Length; i++)
         {
             Add.Invoke(obj, keys.GetValue(i), values.GetValue(i));
         }
     }
 }
示例#19
0
        public async Task <IEnumerable <Produto> > GetAll()
        {
            List <Produto> users;

            try
            {
                IFindFluent <Produto, Produto> findFluent;
                findFluent = CurrentType.Find(c => c.Ativo == true);
                users      = findFluent.ToList();
            }
            catch (Exception e)
            {
                throw;
            }
            return(users);
        }
        public override void ReadBytes(Stream stream, out object obj)
        {
            obj = null;
            int len = stream.ReadInt32();

            if (len != -1)
            {
                object hashset = Activator.CreateInstance(CurrentType);
                for (int i = 0; i < len; i++)
                {
                    var Add = CurrentType.GetMethod("Add");
                    Add.Invoke(hashset, Deserialize(TypeArgs[0], stream));
                }
                obj = hashset;
            }
        }
示例#21
0
        public bool Equals(Type other)
        {
            bool result =
                CurrentType.Equals(other.CurrentType) &&
                Pointer.Equals(other.Pointer) &&
                Reference.Equals(other.Reference) &&
                Array.Equals(other.Array);

            // Note: CLS-compliance and element count do not factor
            // factor into the equality calculations, i.e.
            //  Foo(single[]) == Foo(single[]) -> true
            // even if these types have different element counts.
            // This is necessary because otherwise we'd get
            // redefinition errors in the generated bindings.
            return(result);
        }
示例#22
0
文件: Form1.cs 项目: habb0/Bfly
 internal void AddOrUpdateWire(int x, int y, CurrentType type, WireCurrentTransfer transfer)
 {
     List<Point> result = null;
     result = wireSolver.AddOrUpdateWire(x, y, type, transfer);
     foreach (Point t in result)
     {
         try
         {
             yaaaay[t].updateWireState(wireSolver.getWireTransfer(t));
         }
         catch { }
     }
     StringBuilder sb = new StringBuilder();
     foreach (Point t in result)
     {
         sb.AppendLine(t.ToString());
     }
 }
        protected override void VisitMemberAccessSyntax(MemberAccessSyntax pNode)
        {
            Visit(pNode.Identifier);

            //Save current local definitions
            //Mark the current type we are on so error messages can be more descriptive
            var l = _locals;

            using (var t = Store.AddValue("__Type", pNode.Identifier.Type))
            {
                //If field doesn't exist or something went wrong, stop checking things to reduce redundant errors
                if (CurrentType != SmallTypeCache.Undefined)
                {
                    //For methods and arrays we need to allow existing variables, but member access should only allow the struct's fields
                    if (NeedToCopyLocals(pNode.Value))
                    {
                        _locals = _locals.Copy();
                    }
                    else
                    {
                        _locals = new ScopeCache <LocalDefinition>();
                    }

                    //Namespaces return a null type
                    if (CurrentType != null)
                    {
                        _locals.AddScope();
                        foreach (var f in CurrentType.GetFields())
                        {
                            if (!_locals.IsVariableDefinedInScope(f.Name))
                            {
                                _locals.DefineVariableInScope(f.Name, LocalDefinition.Create(false, f.Type));
                            }
                        }
                    }

                    Visit(pNode.Value);
                }
            }

            //Restore local definitions
            Namespace = null;
            _locals   = l;
        }
示例#24
0
 private void _findTypeOfCurrent()
 {
     if (_entity == null)
     {
         _type = CurrentType.Null;
     }
     else if (_entity is IImmutable)
     {
         _type = CurrentType.Object;
     }
     else if (_entity.GetType().IsImmutableListOfImmutables())
     {
         _type = CurrentType.List;
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
示例#25
0
文件: DumpState.cs 项目: gkowieski/vm
        private DumpState(
            ObjectTextDumper dumper,
            object instance,
            Type type,
            ClassDumpData classDumpData,
            DumpAttribute instanceDumpAttribute,
            DumpScript dumpScript,
            bool isTopLevelClass)
        {
            _dumper               = dumper ?? throw new ArgumentNullException(nameof(dumper));
            _isTopLevelClass      = isTopLevelClass;
            Instance              = instance ?? throw new ArgumentNullException(nameof(instance));
            InstanceType          = instance.GetType();
            CurrentType           = type ?? throw new ArgumentNullException(nameof(type));
            ClassDumpData         = classDumpData;
            InstanceDumpAttribute = instanceDumpAttribute ?? throw new ArgumentNullException(nameof(instanceDumpAttribute));
            DumpScript            = dumpScript;

            if (_isTopLevelClass)
            {
                var defaultProperty = DefaultProperty;

                if (!defaultProperty.IsNullOrWhiteSpace())
                {
                    var pi = CurrentType.GetProperty(defaultProperty);

                    Enumerator = pi != null
                                    ? (new MemberInfo[] { pi }).AsEnumerable().GetEnumerator()
                                    : (new MemberInfo[] { }).AsEnumerable().GetEnumerator();
                    return;
                }
            }

            Enumerator = CurrentType.GetProperties(_dumper.PropertiesBindingFlags | BindingFlags.DeclaredOnly)
                         .Union <MemberInfo>(
                CurrentType.GetFields(_dumper.FieldsBindingFlags | BindingFlags.DeclaredOnly))
                         .Where(mi => !mi.Name.StartsWith("<", StringComparison.Ordinal))
                         .OrderBy(p => p, ServiceResolver
                                  .Default
                                  .GetInstance <IMemberInfoComparer>()
                                  .SetMetadata(ClassDumpData.Metadata))
                         .GetEnumerator();
        }
示例#26
0
        public static List <Type> GetTypesWith <TAttribute>(bool bInherit) where TAttribute : Attribute
        {
            List <Type> AllTypes = new List <Type>();

            Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies();

            foreach (Assembly CurrentAssembly in Assemblies)
            {
                foreach (Type CurrentType in CurrentAssembly.GetTypes())
                {
                    if (CurrentType.IsDefined(typeof(TAttribute), bInherit))
                    {
                        AllTypes.Add(CurrentType);
                    }
                }
            }

            return(AllTypes);
        }
示例#27
0
        public List <Point> AddOrUpdateWire(int x, int y, CurrentType newCurrent, WireCurrentTransfer currentTransfer)
        {
            var result      = new LinkedList <WireTransfer>();
            var updatedWire = getWireTransfer(new Point(x, y));

            if (newCurrent == CurrentType.ON)
            {
            }
            else if (newCurrent == CurrentType.SENDER)
            {
                currentTransfer = WireCurrentTransfer.DOWN | WireCurrentTransfer.LEFT | WireCurrentTransfer.RIGHT | WireCurrentTransfer.UP;
                updatedWire.setCurrentTransfer(currentTransfer);
                updatedWire.setCurrent(CurrentType.SENDER);
                updatePowerGrid(updatedWire, ref result);
            }
            else if (newCurrent == CurrentType.OFF)
            {
                var neighbours = new WireTransfer[4];
                storeNeighbours(updatedWire, neighbours, true);
                updatedWire.setCurrent(CurrentType.OFF);
                updatedWire.setCurrentTransfer(currentTransfer);
                updatePowerGrid(updatedWire, ref result);
                for (var i = 0; i < 4; i++)
                {
                    if (neighbours[i] == null)
                    {
                        continue;
                    }
                    updatePowerGrid(neighbours[i], ref result);
                }
            }
            var finalResult = new List <Point>();

            foreach (var t in result)
            {
                if (!finalResult.Contains(t.location))
                {
                    finalResult.Add(t.location);
                }
            }
            return(finalResult);
        }
示例#28
0
文件: Form1.cs 项目: nightwolf93/Bfly
        internal void AddOrUpdateWire(int x, int y, CurrentType type, WireCurrentTransfer transfer)
        {
            List <Point> result = null;

            result = wireSolver.AddOrUpdateWire(x, y, type, transfer);
            foreach (Point t in result)
            {
                try
                {
                    yaaaay[t].updateWireState(wireSolver.getWireTransfer(t));
                }
                catch { }
            }
            StringBuilder sb = new StringBuilder();

            foreach (Point t in result)
            {
                sb.AppendLine(t.ToString());
            }
        }
        public static ProcessStartInfo GetStartInfo(PowerMode powermode, CurrentType ct, bool enable)
        {
            var info = new ProcessStartInfo();

            info.FileName        = "powercfg";
            info.CreateNoWindow  = true;  // コンソール・ウィンドウを開かない
            info.UseShellExecute = false; // シェル機能を使用しない

            string args = string.Empty;

            switch (powermode)
            {
            case PowerMode.Sleep:
                args += "-change -standby-timeout";
                break;

            case PowerMode.Display:
                args += "-change -monitor-timeout";
                break;
            }

            switch (ct)
            {
            case CurrentType.AC:
                args += "-dc ";
                break;

            case CurrentType.DC:
                args += "-ac ";
                break;
            }

            args += (autodisplayoff ? "1" : "0");

            info.Arguments = args;

            return(info);
        }
示例#30
0
 public List<Point> AddOrUpdateWire(int x, int y, CurrentType newCurrent, WireCurrentTransfer currentTransfer)
 {
     LinkedList<WireTransfer> result = new LinkedList<WireTransfer>();
     WireTransfer updatedWire = getWireTransfer(new Point(x, y));
     if(newCurrent == CurrentType.ON)
     {
     }
     else if (newCurrent == CurrentType.SENDER)
     {
         currentTransfer = WireCurrentTransfer.DOWN | WireCurrentTransfer.LEFT | WireCurrentTransfer.RIGHT | WireCurrentTransfer.UP;
         updatedWire.setCurrentTransfer(currentTransfer);
         updatedWire.setCurrent(CurrentType.SENDER);
         updatePowerGrid(updatedWire, ref result);
     }
     else if (newCurrent == CurrentType.OFF)
     {
         WireTransfer[] neighbours = new WireTransfer[4];
         storeNeighbours(updatedWire, neighbours, true);
         updatedWire.setCurrent(CurrentType.OFF);
         updatedWire.setCurrentTransfer(currentTransfer);
         updatePowerGrid(updatedWire, ref result);
         for (int i = 0; i < 4; i++)
         {
             if (neighbours[i] == null)
                 continue;
             updatePowerGrid(neighbours[i], ref result);
         }
     }
     List<Point> finalResult = new List<Point>();
     foreach (WireTransfer t in result)
     {
         if (!finalResult.Contains(t.location))
             finalResult.Add(t.location);
     }
     return finalResult;
 }
示例#31
0
        private void UpdateContextTypeIfChanged()
        {
            if (IsConnected && DTE.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
            {
                string currentFunction = DTE.Debugger.CurrentStackFrame.FunctionName;

                Log("ExtendedImmediateAddInn - Connect");
                Log("Current Func: " + currentFunction);

                if (currentFunction != LastStackFunction)
                {
                    Log("-> not cached already, have to analyze " + currentFunction);
                    CurrentType = DTE.Debugger.GetCurrentType();
                    Log("CurrentType: " + CurrentType.ToString());
                    var context = GetContextType();
                    Log("ContextType (compiled in background): " + context.ToString());
                    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                    ViewController.SetContextType(context);
                    AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                    LastStackFunction = currentFunction;
                    Log("Done.");
                }
            }
        }
示例#32
0
		void push(CurrentType type, Object obj)
		{
			Debug.WriteLine("XamlParser: PUSHING: " + oldStates.Count + " " + type);
			ParserState currentState = new ParserState();
			currentState.type = type;
			currentState.obj = obj;
			oldStates.Add(currentState);
		}
示例#33
0
        public virtual void Translate(string category)
        {
            Enum   @enum;
            string s;

            if (this.CurrentType == "BlendEquationModeEXT")
            {
            }

            // Try to find out if it is an enum. If the type exists in the normal GLEnums list, use this.
            // Otherwise, try to find it in the aux enums list. If it exists in neither, it is not an enum.
            // Special case for Boolean - it is an enum, but it is dumb to use that instead of the 'bool' type.
            bool normal = false;
            bool aux    = false;

            normal = Enum.GLEnums.TryGetValue(CurrentType, out @enum);
            if (!normal)
            {
                aux = Enum.AuxEnums != null && Enum.AuxEnums.TryGetValue(CurrentType, out @enum);
            }

            // Translate enum types
            if ((normal || aux) && @enum.Name != "GLenum" && @enum.Name != "Boolean")
            {
                if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) != Settings.Legacy.None)
                {
                    CurrentType = "int";
                }
                else
                {
                    if (normal)
                    {
                        CurrentType = Enum.TranslateName(CurrentType).Insert(0, String.Format("{0}.", Settings.EnumsOutput));
                    }
                    else if (aux)
                    {
                        CurrentType = Enum.TranslateName(CurrentType).Insert(0, String.Format("{0}.", Settings.EnumsAuxOutput));
                    }
                }
            }
            else if (Bind.Structures.Type.GLTypes.TryGetValue(CurrentType, out s))
            {
                // Check if the parameter is a generic GLenum. If yes,
                // check if a better match exists:
                if (s.Contains("GLenum") && !String.IsNullOrEmpty(category))
                {
                    if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) != Settings.Legacy.None)
                    {
                        CurrentType = "int";
                    }
                    else
                    // Better match: enum.Name == function.Category (e.g. GL_VERSION_1_1 etc)
                    if (Enum.GLEnums.ContainsKey(category))
                    {
                        CurrentType = String.Format("{0}.{1}", Settings.EnumsOutput, Enum.TranslateName(category));
                    }
                    else
                    {
                        CurrentType = String.Format("{0}.{1}", Settings.EnumsOutput, Settings.CompleteEnumName);
                    }
                }
                else
                {
                    // This is not enum, default translation:
                    if (CurrentType == "PIXELFORMATDESCRIPTOR" || CurrentType == "LAYERPLANEDESCRIPTOR" ||
                        CurrentType == "GLYPHMETRICSFLOAT")
                    {
                        if (Settings.Compatibility == Settings.Legacy.Tao)
                        {
                            CurrentType = CurrentType.Insert(0, "Gdi.");
                        }
                        else
                        {
                            if (CurrentType == "PIXELFORMATDESCRIPTOR")
                            {
                                CurrentType = "PixelFormatDescriptor";
                            }
                            else if (CurrentType == "LAYERPLANEDESCRIPTOR")
                            {
                                CurrentType = "LayerPlaneDescriptor";
                            }
                            else if (CurrentType == "GLYPHMETRICSFLOAT")
                            {
                                CurrentType = "GlyphMetricsFloat";
                            }
                        }
                    }
                    else if (CurrentType == "XVisualInfo")
                    {
                        //p.Pointer = false;
                        //p.Reference = true;
                    }
                    else
                    {
                        CurrentType = s;
                    }
                }

                CurrentType =
                    Bind.Structures.Type.CSTypes.ContainsKey(CurrentType) ?
                    Bind.Structures.Type.CSTypes[CurrentType] : CurrentType;

                if (CurrentType == "IntPtr" && String.IsNullOrEmpty(PreviousType))
                {
                    Pointer = false;
                }
            }
        }
示例#34
0
 internal void setCurrent(CurrentType currentType)
 {
     this.Current = currentType;
 }