Ejemplo n.º 1
0
 public VariableDeclaration(Position pos, Symbol name, NameType type, Expression init)
 {
     Pos = pos;
     Name = name;
     Type = type;
     Init = init;
 }
Ejemplo n.º 2
0
        protected ReflectedGetterSetter(MethodInfo[]/*!*/ getter, MethodInfo[]/*!*/ setter, NameType nt) {
            Debug.Assert(getter != null);
            Debug.Assert(setter != null);

            _getter = RemoveNullEntries(getter);
            _setter = RemoveNullEntries(setter);
            _nameType = nt;
        }
 /// <summary>
 /// Prepares help text for given option string <paramref name="name"/> and its <paramref name="type"/>.
 /// </summary>
 /// <param name="name">Option string.</param>
 /// <param name="type">Type of given option string. <see cref="NameType"/> for possible values (Short or Long).</param>
 /// <returns>Help string for given option.</returns>
 /// <seealso cref="NameType" />
 /// <seealso cref="ParameterName"/>
 /// <remarks>Uses ParameterName for displaying the required parameter./>.
 /// <example><para><c>-f</c> is short option string</para><para><c>--format</c> is long option string</para></example></remarks>
 protected override string GetHelpTextForName(string name, NameType type)
 {
     switch (type) {
         case NameType.Short: return string.Format("-{0} {1}", name, Printer.GetParameterName(ParameterName));
         case NameType.Long: return string.Format("--{0}={1}", name, Printer.GetParameterName(ParameterName));
         default: throw new NotImplementedException();
     }
 }
Ejemplo n.º 4
0
 public void Init(string name, NameType type, bool stackable = true)
 {
     this.name = name;
     this.Type = type;
     this.IsStackable = stackable;
     this.effects = new List<Effect>();
     this.prepositions = new List<string>();
 }
Ejemplo n.º 5
0
 public FunctionDeclaration(Position pos, Symbol name, FieldList param, NameType result, Expression body, FunctionDeclaration next)
 {
     Pos = pos;
     Name = name;
     Param = param;
     Result = result;
     Body = body;
     Next = next;
 }
Ejemplo n.º 6
0
        internal static NameType GetNameFromMethod(TotemType dt, MethodInfo mi, NameType res, ref string name)
        {
            string namePrefix = null;

            if (mi.IsPrivate || (mi.IsAssembly && !mi.IsFamilyOrAssembly))
            {
                // allow explicitly implemented interface
                if (!(mi.IsPrivate && mi.IsFinal && mi.IsHideBySig && mi.IsVirtual))
                {
                    // mangle protectes to private
                    namePrefix = "_" + dt.Name + "__";
                }
                else
                {
                    // explicitly implemented interface

                    // drop the namespace, leave the interface name, and replace 
                    // the dot with an underscore.  Eg System.IConvertible.ToBoolean
                    // becomes IConvertible_ToBoolean
                    int lastDot = name.LastIndexOf('.');
                    if (lastDot != -1)
                        name = name.Substring(lastDot + 1);
                }
            }

            if (namePrefix != null) name = namePrefix + name;

            if (mi.DeclaringType.GetTypeInfo().IsDefined(typeof(TotemTypeAttribute), false) ||
                !mi.DeclaringType.IsAssignableFrom(dt.UnderlyingSystemType))
            {
                // extension types are all totem names
                res |= NameType.Totem;
            }

            //if (mi.IsDefined(typeof(TotemMethodAttribute), false))
            //{
            //    res = NameType(res & ~NameType.BaseTypeMask) | NameType.Property;
            //}

            return res;
        }
    public static string[] PickFullName(NameType nameType, Gender gender)
    {
        switch (nameType)
        {
        case NameType.RandomName:
            string firstName = gender == Gender.Male
                    ? Util.GetRandomValue(FirstNamesMale)
                    : Util.GetRandomValue(FirstNamesFemale);
            return(new string[] { firstName, Util.GetRandomValue(LastNames) });

        case NameType.ExistingCombination:
            NameCombination name = gender == Gender.Male
                    ? Util.GetRandomValue(ExistingCombinationsMale)
                    : Util.GetRandomValue(ExistingCombinationsFemale);
            return(new string[] { name.FirstName, name.LastName });

        default:
            Logger.Error(Logger.Character, "Not implemented name type {0}", nameType);
            return(new string[] { });
        }
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Remove a netbios name.
        /// </summary>
        /// <param name="name">The name to remove.</param>
        /// <param name="type">The type used.</param>
        /// <param name="suffix">The suffix used.</param>
        /// <returns>True on success, false on failure.</returns>
        public bool RemoveName(string name, NameType type, MsSuffix suffix)
        {
            Name node = new Name();

            node.UncompressedName = UncompressName(name, suffix);
            node.Type             = type;

            lock (nameList)
            {
                int i = 0;
                for (; i < nameList.Count; i++)
                {
                    Name n = (Name)nameList[i];
                    if ((n.UncompressedName == node.UncompressedName) && (n.Type == node.Type))
                    {
                        break;
                    }
                }

                if (i >= nameList.Count)
                {
                    return(false);   // Name not found
                }
                nameList.RemoveAt(i);

                if (nameList.Count == 0)
                {
                    updateTimer.Change(Timeout.Infinite, Timeout.Infinite);
                }
            }

            // Send request
            for (int i = 0; i < BCAST_REQ_RETRY_COUNT; i++)
            {
                Request(node, HeaderOpcode.Release);
                Thread.Sleep(BCAST_REQ_RETRY_TIMEOUT);
            }

            return(true);
        }
Ejemplo n.º 9
0
    private Character FindCharacter(string satanisedName, NameType nameType)
    {
        List <Character> charactersInGame = CharacterManager.Instance.Characters;

        Character characterToDelete = null;

        Logger.Log("Trying to find {0}", satanisedName);
        if (nameType == NameType.FullName)
        {
            characterToDelete = charactersInGame.Find(i => CharacterNameGenerator.GetName(i.CharacterName).ToLower() == satanisedName);
        }
        if (characterToDelete == null && (nameType == NameType.FirstName || nameType == NameType.FullName))
        {
            characterToDelete = charactersInGame.Find(i => i.CharacterName.FirstName.ToLower() == satanisedName);
        }
        if (characterToDelete == null && (nameType == NameType.LastName || nameType == NameType.FullName))
        {
            characterToDelete = charactersInGame.Find(i => i.CharacterName.LastName.ToLower() == satanisedName);
        }

        return(characterToDelete);
    }
Ejemplo n.º 10
0
        public static NameType TryGetName(DynamicType dt, PropertyInfo pi, MethodInfo prop, out string name)
        {
            name = null;
            string   namePrefix = "";
            NameType res        = NameType.Property;

            if (prop.IsPrivate || (prop.IsAssembly && !prop.IsFamilyOrAssembly))
            {
                // allow explicitly implemented interface
                if (!(prop.IsPrivate && prop.IsFinal && prop.IsHideBySig && prop.IsVirtual))
                {
                    if (!Options.PrivateBinding)
                    {
                        return(NameType.None);
                    }
                    else
                    {
                        // mangle protectes to private
                        namePrefix = "_" + dt.__name__ + "__";
                    }
                }
            }

            object[] attribute = prop.GetCustomAttributes(typeof(PythonNameAttribute), false);

            name = namePrefix + pi.Name;
            if (attribute.Length > 0)
            {
                PythonNameAttribute attr = attribute[0] as PythonNameAttribute;
                if (attr.name != null && attr.name.Length > 0)
                {
                    res  = NameType.PythonProperty;
                    name = attr.name;
                }
            }


            return(res);
        }
Ejemplo n.º 11
0
        private async Task RunNamesCommands(IUser User, NameType NameType)
        {
            if (User == null)
            {
                User = Context.User;
            }

            List <NameRecord> Names = UserRecordsService.GetNameRecords(User, NameType).ToList();

            Names.Sort((a, b) => b.SetTime.CompareTo(a.SetTime));

            EmbedBuilder[] Menu = BuildNicknameEmbeds(Names.ToArray(), $"{NameType} Record for User {User.Username}#{User.Discriminator}");

            if (Menu.Length == 1)
            {
                await Menu[0].SendEmbed(Context.Channel);
            }
            else
            {
                await CreateReactionMenu(Menu, Context.Channel);
            }
        }
Ejemplo n.º 12
0
        private void AddReflectedUnboundMethod(MethodInfo mi)
        {
            if (!mi.IsStatic)
            {
                return;
            }

            string   name;
            NameType nt = NameConverter.TryGetName(this, mi, out name);

            if (nt == NameType.None)
            {
                return;
            }

            FunctionType funcType = FunctionType.Method;

            if (mi.DeclaringType == typeof(ArrayOps))
            {
                funcType |= FunctionType.SkipThisCheck;
            }
            if (nt == NameType.PythonMethod)
            {
                funcType |= FunctionType.PythonVisible;
            }

            RemoveNonOps(SymbolTable.StringToId(name));

            // store Python version
            StoreMethod <ReflectedUnboundMethod>(name, mi, funcType | FunctionType.OpsFunction);

            // store CLR version, if different and we don't have a clash (if we do
            // have a clash our version is still available under the python name)
            if (name != mi.Name && !ContainsNonOps(SymbolTable.StringToId(mi.Name)))
            {
                StoreMethod <ReflectedUnboundMethod>(mi.Name, mi, FunctionType.Method | FunctionType.OpsFunction);
            }
        }
Ejemplo n.º 13
0
            private static List <string> GetMixedNameList(NameType type)
            {
                List <string> al = new List <string>();

                if ((type & NameType.MaleName) == NameType.MaleName)
                {
                    FillListFromList(al, MaleNames);
                }
                if ((type & NameType.FemaleName) == NameType.FemaleName)
                {
                    FillListFromList(al, FemaleNames);
                }
                if ((type & NameType.Surname) == NameType.Surname)
                {
                    FillListFromList(al, Surnames);
                }
                if ((type & NameType.Word) == NameType.Word)
                {
                    FillListFromList(al, Words);
                }

                return(al);
            }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (TradingName != null)
         {
             hashCode = hashCode * 59 + TradingName.GetHashCode();
         }
         if (Href != null)
         {
             hashCode = hashCode * 59 + Href.GetHashCode();
         }
         if (IsLegalEntity != null)
         {
             hashCode = hashCode * 59 + IsLegalEntity.GetHashCode();
         }
         if (OrganizationType != null)
         {
             hashCode = hashCode * 59 + OrganizationType.GetHashCode();
         }
         if (NameType != null)
         {
             hashCode = hashCode * 59 + NameType.GetHashCode();
         }
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Removes all names on <paramref name="User"/> following a given <paramref name="Pattern"/> from their records.
        /// </summary>
        /// <param name="User">The target user.</param>
        /// <param name="NameType">Whether to target NICKNAMEs or USERNAMEs.</param>
        /// <param name="Pattern">The pattern to follow deletion, a regular expression if <paramref name="IsRegex"/>, otherwise the verbatim nickname.</param>
        /// <param name="IsRegex">Whether <paramref name="Pattern"/> should be interpreted as a regular expression.</param>
        /// <returns>A List of strings containing all nicknames that fit <paramref name="Pattern"/>.</returns>

        public List <NameRecord> RemoveNames(IUser User, NameType NameType, string Pattern, bool IsRegex = false)
        {
            List <NameRecord> Result  = new();
            List <NameRecord> Records = ProfilesDB.Names.Where(n => n.Type == NameType && n.UserID == User.Id).ToList();

            Pattern = Pattern.Trim();

            if (IsRegex)
            {
                foreach (NameRecord Record in Records)
                {
                    if (Regex.Match(Record.Name, Pattern).Success)
                    {
                        ProfilesDB.Names.Remove(Record);
                        Result.Add(Record.Clone());
                    }
                }
            }
            else
            {
                foreach (NameRecord Record in Records)
                {
                    if (Record.Name == Pattern)
                    {
                        ProfilesDB.Names.Remove(Record);
                        Result = new List <NameRecord>()
                        {
                            Record.Clone()
                        };
                        break;
                    }
                }
            }

            ProfilesDB.SaveChanges();
            return(Result);
        }
Ejemplo n.º 16
0
        private static Name GetNameFromIdentifiersHelper(List <Identifier> identifiers, NameType nameType, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (count == 1)
            {
                return(new Name(identifiers[0], null, nameType));
            }
            else
            {
                NameType newNameType;
                switch (nameType)
                {
                case NameType.Module:
                case NameType.Package:
                case NameType.PackageOrType:
                case NameType.Ambiguous:
                    newNameType = nameType;
                    break;

                case NameType.Type:
                    newNameType = NameType.PackageOrType;
                    break;

                case NameType.Expression:
                    newNameType = NameType.Ambiguous;
                    break;

                default: // NameType.Method
                    throw new InvalidOperationException();
                }
                Name parent = GetNameFromIdentifiersHelper(identifiers, newNameType, count - 1);
                return(new Name(identifiers[count - 1], parent, nameType));
            }
        }
Ejemplo n.º 17
0
        private Type ParseDataType(string dt, string dtValues)
        {
            string strType = dt;

            string[] parts = dt.Split(':');

            if (parts.Length > 2)
            {
                throw ExceptionBuilder.InvalidAttributeValue("type", dt);
            }
            else if (parts.Length == 2)
            {
                // CONSIDER: check that we have valid prefix
                strType = parts[1];
            }

            NameType nt = FindNameType(strType);

            if (nt == s_enumerationNameType && (dtValues == null || dtValues.Length == 0))
            {
                throw ExceptionBuilder.MissingAttribute("type", Keywords.DT_VALUES);
            }
            return(nt.type);
        }
Ejemplo n.º 18
0
        public override string Update(Job job, Phase phase, string body = null, string contentType = null, string accept = null)
        {
            job.UpdateState(JobStateType.INPROGRESS, "UPDATE to " + phase.Name);
            if (!contentType.ToLower().Equals("application/json"))
            {
                string msg = "Invalid Content-Type, expecting application/json";
                job.UpdatePhaseState(phase.Name, PhaseStateType.FAILED, msg);
                throw new RejectedException(msg);
            }
            LearnerPersonal data;

            try {
                data = JsonConvert.DeserializeObject <LearnerPersonal>(body);
            } catch (Exception e)
            {
                string msg = "Error decoding Json data: " + e.Message;
                job.UpdatePhaseState(phase.Name, PhaseStateType.FAILED, msg);
                throw new RejectedException(msg, e);
            }
            NameType name = data.PersonalInformation.Name;

            job.UpdatePhaseState(phase.Name, PhaseStateType.COMPLETED, "UPDATE");
            return("Got UPDATE message for " + phase.Name + "@" + job.Id + " with content type " + contentType + " and accept " + accept + ".\nGot record for learner:" + name.GivenName + " " + name.FamilyName);
        }
        public string Generate(NameType type = NameType.Both, Gender gender = Gender.Both)
        {
            string name;

            switch (type)
            {
            case NameType.Given:
                name = GenerateGiven(gender);
                break;

            case NameType.Surname:
                name = GenerateSurname();
                break;

            case NameType.Both:
                name = GenerateFull(gender);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(gender));
            }

            return(name);
        }
Ejemplo n.º 20
0
        private Type ParseDataType(string dt, string dtValues)
        {
            string strType = dt;

            string[] parts = dt.Split(colonArray);  // ":"

            if (parts.Length > 2)
            {
                throw ExceptionBuilder.InvalidAttributeValue("type", dt);
            }
            else if (parts.Length == 2)
            {
                //
                strType = parts[1];
            }

            NameType nt = FindNameType(strType);

            if (nt == enumerationNameType && (dtValues == null || dtValues.Length == 0))
            {
                throw ExceptionBuilder.MissingAttribute("type", Keywords.DT_VALUES);
            }
            return(nt.type);
        }
Ejemplo n.º 21
0
        private static void Deactivate(NameType name, int row)
        {
            switch (name)
            {
            case NameType.ConfirmOptIn:
                deactivateProcess(row);
                break;

            case NameType.ScheduledMessageStatusChange:
                deactivateProcess(row);
                break;

            case NameType.ScheduleMessage:
                deactivateProcess(row);
                break;

            case NameType.SendMessage:
                deactivateProcess(row);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 22
0
        public static string GetName(NameType type, string table, string[] columns = null, string alt = null)
        {
            var name = new StringBuilder();

            switch (type)
            {
            case NameType.PrimaryKey:
                name.Append("PK_");
                break;

            case NameType.UniqueKey:
                name.Append("UK_");
                break;

            case NameType.Index:
                name.Append("IX_");
                break;

            case NameType.ForeignKey:
                name.Append("FK_");
                break;
            }

            name.Append(table.Replace('.', '_'));
            if (columns != null)
            {
                name.Append("_").Append(string.Join("_", columns));
            }

            if (alt != null)
            {
                name.Append("_").Append(alt.Replace('.', '_'));
            }

            return(name.ToString());
        }
Ejemplo n.º 23
0
 // define a parameterized constructor
 public Person(NameType type, string value)
 {
     Console.WriteLine("Parameterized person constructor invoked");
 }
Ejemplo n.º 24
0
 public ReflectedIndexer(PropertyInfo/*!*/ info, NameType nt, bool privateBinding)
     : base(new MethodInfo[] { info.GetGetMethod(privateBinding) }, new MethodInfo[] { info.GetSetMethod(privateBinding) }, nt) {
     Debug.Assert(info != null);
     
     _info = info;
 }
Ejemplo n.º 25
0
        public ReflectedProperty(PropertyInfo info, MethodInfo getter, MethodInfo setter, NameType nt)
            : base(new MethodInfo[] { getter }, new MethodInfo[] { setter }, nt) {
            Debug.Assert(info != null);

            _info = info;
        }
Ejemplo n.º 26
0
 public ReflectedExtensionProperty(ExtensionPropertyInfo info, NameType nt)
     : base(new MethodInfo[] { info.Getter }, new MethodInfo[] { info.Setter }, nt)
 {
     _extInfo = info;
     _deleter = info.Deleter;
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Gets the name of the contact
 /// </summary>
 /// <param name="strSubject">buffer to contain output string</param>
 /// <param name="nType">NameType to specify which name to retrieve</param>
 /// <returns>true on success</returns>
 public bool GetName(StringBuilder strSubject, NameType nType)
 {
     return ContactGetName(pObject, strSubject, strSubject.Capacity, (int)nType);
 }
Ejemplo n.º 28
0
        private static NameType GetNameFromMethod(ReflectedType dt, MethodInfo mi, NameType res, ref string name)
        {
            string namePrefix = null;

            if (mi.IsPrivate || (mi.IsAssembly && !mi.IsFamilyOrAssembly)) {
                // allow explicitly implemented interface
                if (!(mi.IsPrivate && mi.IsFinal && mi.IsHideBySig && mi.IsVirtual)) {
                    if (!Options.PrivateBinding) {
                        return NameType.None;
                    } else {
                        // mangle protectes to private
                        namePrefix = "_" + dt.Name + "__";
                    }
                } else {
                    // explicitly implemented interface

                    // drop the namespace, leave the interface name, and replace
                    // the dot with an underscore.  Eg System.IConvertible.ToBoolean
                    // becomes IConvertible_ToBoolean
                    int lastDot = name.LastIndexOf(Type.Delimiter);
                    if (lastDot != -1) {
                        name = name.Substring(lastDot + 1);
                    }
                }
            }

            object[] attribute = mi.GetCustomAttributes(typeof(PythonNameAttribute), false);

            if (namePrefix != null) name = namePrefix + name;
            if (attribute.Length > 0) {
                PythonNameAttribute attr = attribute[0] as PythonNameAttribute;
                if (attr.name != null && attr.name.Length > 0) {
                    if (attr is PythonClassMethodAttribute) res |= NameType.ClassMember;

                    res |= NameType.Python;
                    name = attr.name;
                }
            }

            return res;
        }
Ejemplo n.º 29
0
 protected string generate_string(NameType t)
 {
     if (t == BattleName.NameType.First)
     {
         NamePattern p = new NamePattern(5, 8);
         NamePattern.Token[] tp = p.GenerateLogicalPattern (this.rand);
         return this.from_pattern (tp);
     }
     else
     {
         NamePattern p = new NamePattern(5, 13);
         NamePattern.Token[] tp = p.GenerateLogicalPattern (this.rand);
         return this.from_pattern (tp);
     }
 }
Ejemplo n.º 30
0
        internal static ReflectedGetterSetter GetReflectedProperty(PropertyTracker pt, MemberGroup allProperties, bool privateBinding)
        {
            ReflectedGetterSetter rp;

            lock (_propertyCache) {
                if (_propertyCache.TryGetValue(pt, out rp))
                {
                    return(rp);
                }

                NameType   nt     = NameType.PythonProperty;
                MethodInfo getter = FilterProtectedGetterOrSetter(pt.GetGetMethod(true), privateBinding);
                MethodInfo setter = FilterProtectedGetterOrSetter(pt.GetSetMethod(true), privateBinding);

                if ((getter != null && PythonHiddenAttribute.IsHidden(getter, true)) ||
                    (setter != null && PythonHiddenAttribute.IsHidden(setter, true)))
                {
                    nt = NameType.Property;
                }

                ExtensionPropertyTracker ept = pt as ExtensionPropertyTracker;
                if (ept == null)
                {
                    ReflectedPropertyTracker rpt = pt as ReflectedPropertyTracker;
                    Debug.Assert(rpt != null);

                    if (PythonBinder.IsExtendedType(pt.DeclaringType) ||
                        PythonHiddenAttribute.IsHidden(rpt.Property, true))
                    {
                        nt = NameType.Property;
                    }

                    if (pt.GetIndexParameters().Length == 0)
                    {
                        List <MethodInfo> getters = new List <MethodInfo>();
                        List <MethodInfo> setters = new List <MethodInfo>();

                        IList <ExtensionPropertyTracker> overriddenProperties = NewTypeMaker.GetOverriddenProperties((getter ?? setter).DeclaringType, pt.Name);
                        foreach (ExtensionPropertyTracker tracker in overriddenProperties)
                        {
                            MethodInfo method = tracker.GetGetMethod(privateBinding);
                            if (method != null)
                            {
                                getters.Add(method);
                            }

                            method = tracker.GetSetMethod(privateBinding);
                            if (method != null)
                            {
                                setters.Add(method);
                            }
                        }

                        foreach (PropertyTracker propTracker in allProperties)
                        {
                            MethodInfo method = propTracker.GetGetMethod(privateBinding);
                            if (method != null)
                            {
                                getters.Add(method);
                            }

                            method = propTracker.GetSetMethod(privateBinding);
                            if (method != null)
                            {
                                setters.Add(method);
                            }
                        }
                        rp = new ReflectedProperty(rpt.Property, getters.ToArray(), setters.ToArray(), nt);
                    }
                    else
                    {
                        rp = new ReflectedIndexer(((ReflectedPropertyTracker)pt).Property, NameType.Property, privateBinding);
                    }
                }
                else
                {
                    rp = new ReflectedExtensionProperty(new ExtensionPropertyInfo(pt.DeclaringType, getter ?? setter), nt);
                }

                _propertyCache[pt] = rp;

                return(rp);
            }
        }
 /// <summary>
 /// Prepares help text for given option string <paramref name="name"/> and its <paramref name="type"/>.
 /// </summary>
 /// <param name="name">Option string.</param>
 /// <param name="type">Type of given option string. <see cref="NameType"/> for possible values (Short or Long).</param>
 /// <returns>Help string for given option.</returns>
 /// <seealso cref="NameType" />
 /// <example><para><c>-f</c> is short option string</para><para><c>--format</c> is long option string</para></example>
 protected virtual string GetHelpTextForName(string name, NameType type)
 {
     switch (type) {
         case NameType.Short: return string.Format("-{0}", name);
         case NameType.Long: return string.Format("--{0}", name);
         default: throw new NotImplementedException();
     }
 }
        protected virtual MetaMetadata FindOrGenerateInheritedMetaMetadata(MetaMetadataRepository repository, InheritanceHandler inheritanceHandler)
        {
            MetaMetadata inheritedMmd = this.TypeMmd;
            if (inheritedMmd == null)
            {
                MmdScope mmdScope = this.Scope;
                String inheritedMmdName = Type ?? Name;

                if (ExtendsAttribute != null)
                {
                    // determine new type name
                    if (inheritedMmdName == null)
                        throw new MetaMetadataException("attribute 'name' must be specified: " + this);
                    if (inheritanceHandler.ResolveMmdName(inheritedMmdName) != null)
                        // currently we don't encourage re-using existing name. however, in the future, when package names are available, we can change this.
                        throw new MetaMetadataException("meta-metadata '" + inheritedMmdName + "' already exists! please use another name to prevent name collision. hint: use 'tag' to change the tag if needed.");

                    // determine from which meta-metadata to inherit
                    inheritedMmd = inheritanceHandler.ResolveMmdName(ExtendsAttribute);
                    if (ExtendsAttribute == null || inheritedMmd == null)
                        throw new MetaMetadataException("super type not specified or recognized: " + this + ", super type name: " + ExtendsAttribute);

                    // generate inline mmds and put it into current scope
                    MetaMetadata generatedMmd = this.GenerateMetaMetadata(inheritedMmdName, inheritedMmd);
                    mmdScope.Put(inheritedMmdName, generatedMmd);
                    mmdScope.Put(generatedMmd.Name, generatedMmd);

                    // recursively do inheritance on generated mmd
                    generatedMmd.InheritMetaMetadata(null); // this will set generateClassDescriptor to true if necessary

                    MakeThisFieldUseMmd(inheritedMmdName, generatedMmd);
                    return generatedMmd;
                }
                else
                {
                    // use type / extends
                    if (inheritedMmdName == null)
                        throw new MetaMetadataException("no type / extends defined for " + this
                            + " (note that due to a limitation explicit child_scalar_type is needed for scalar collection fields, even if it has been declared in super field).");

                    NameType[] nameType = new NameType[1];
                    inheritedMmd = inheritanceHandler.ResolveMmdName(inheritedMmdName, nameType);

                    if (inheritedMmd == null)
                        throw new MetaMetadataException("meta-metadata not found: " + inheritedMmdName + " (if you want to define new types inline, you need to specify extends/child_extends).");

                    if (!inheritedMmdName.Equals(inheritedMmd.Name) && nameType[0] == NameType.MMD)
                    {
                        // could be inline mmd
                        this.MakeThisFieldUseMmd(inheritedMmdName, inheritedMmd);
                    }

                    // process normal mmd / field
                    Debug.WriteLine("setting " + this + ".inheritedMmd to " + inheritedMmd);
                    TypeMmd = inheritedMmd;
                }
            }
            return inheritedMmd;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Remove a netbios name.
        /// </summary>
        /// <param name="name">The name to remove.</param>
        /// <param name="type">The type used.</param>
        /// <param name="suffix">The suffix used.</param>
        /// <returns>True on success, false on failure.</returns>
        public bool RemoveName(string name, NameType type, MsSuffix suffix)
        {
            Name node = new Name();
            node.UncompressedName = UncompressName(name, suffix);
            node.Type = type;

            lock (nameList)
            {
                int i = 0;
                for (; i < nameList.Count; i++)
                {
                    Name n = (Name)nameList[i];
                    if ((n.UncompressedName == node.UncompressedName) && (n.Type == node.Type))
                        break;
                }

                if (i >= nameList.Count)
                    return false;   // Name not found

                nameList.RemoveAt(i);

                if (nameList.Count == 0)
                    updateTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }

            // Send request
            for (int i = 0; i < BCAST_REQ_RETRY_COUNT; i++)
            {
                Request(node, HeaderOpcode.Release);
                Thread.Sleep(BCAST_REQ_RETRY_TIMEOUT);
            }

            return true;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Add a netbios name.
        /// </summary>
        /// <param name="name">The name to add.</param>
        /// <param name="type">The type to use.</param>
        /// <param name="suffix">The suffix to use.</param>
        /// <returns>True on success, false on failure.</returns>
        public bool AddName(string name, NameType type, MsSuffix suffix)
        {
            Name node = new Name();
            node.UncompressedName = UncompressName(name, suffix);
            node.Type = type;

            // Send request
            StartCapture();

            for (int i = 0; i < BCAST_REQ_RETRY_COUNT; i++)
            {
                Request(node, HeaderOpcode.Registration);
                Thread.Sleep(3 * BCAST_REQ_RETRY_TIMEOUT);  // Three times, otherwise FEZ can't follow :(

                if (denyCaptured)
                    break;
            }

            if (!StopCapture())
                return false;   // Name in use

            Request(node, HeaderOpcode.Update);

            lock (nameList)
                nameList.Add(node);

            updateTimer.Change(NAME_UPDATE_INTERVAL_MS, Timeout.Infinite);

            return true;
        }
Ejemplo n.º 35
0
        public ReflectedProperty(PropertyInfo info, MethodInfo getter, MethodInfo setter, NameType nt)
            : base(new MethodInfo[] { getter }, new MethodInfo[] { setter }, nt)
        {
            Debug.Assert(info != null);

            _info = info;
        }
Ejemplo n.º 36
0
 /// <summary>
 /// 创建一个.log文件
 /// </summary>
 /// <param name="tpath"></param>
 /// <param name="tsn"></param>
 /// <param name="ttype"></param>
 public void CreateTXT(string tpath, string tsn, NameType ttype = NameType.None)
 {
     Create(tpath, tsn, ".log", ttype);
 }
Ejemplo n.º 37
0
 public RVVisibility(NameType n, Type v)
 {
     this.RVType    = n;
     this.ValueType = v;
 }
    // # Create Account   	
    public CreateAccountRequest CreateAccount() 
    {
        // Request envelope object
        RequestEnvelope envelopeRequest = new RequestEnvelope();	
	
        // The name of the person for whom the PayPal account is created:
        //  
        // * FirstName  		
        // * LastName   		
        NameType name = new NameType("John", "David");	
	
        // The address to be associated with the PayPal account:    
        //      
        // * Street1    		
        // * countrycode    		
        // * city   		
        // * state  		
        // * postalcode 		
        AddressType address = new AddressType("Ape Way", "US");		
        address.city = "Austin";		
        address.state = "TX";		
        address.postalCode ="78750";

        // The CreateAccountRequest contains the information required    
        // to create a PayPal account for a business customer   
        // Instantiating createAccountRequest with mandatory arguments: 
		//      
        // * requesteEvelope    		
        // * name   		
        // * address    		
        // * preferredlanguagecode  	
        CreateAccountRequest createAccountRequest = new CreateAccountRequest(envelopeRequest, name, address, "en_US");		
        
        // The type of account to be created    
        // Allowable values:   
 		//      
        // * Personal    	
        // * Premier        	
        // * Business         		        
        createAccountRequest.accountType = "Personal";
		
        // The code of the country to be associated with the account       		
        createAccountRequest.citizenshipCountryCode = "US";		
        
        // Phone Number to be associated with the account   		
        createAccountRequest.contactPhoneNumber ="5126914160";		

        // The three letter code for the currency to be associated with the account 	
        createAccountRequest.currencyCode ="USD";   		
        
        // Email address of person for whom the PayPal account is created   		
        createAccountRequest.emailAddress = "*****@*****.**";  	
	
        // This attribute determines whether a key or a URL is returned for the redirect URL          
        createAccountRequest.registrationType = "Web";

        // IPN URL
        //      
        // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed        
        // * The transaction related IPN variables will be received on the call back URL specified in the request       
        // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"     
        // * PayPal would continuously resend IPN if a wrong IPN is sent        
        createAccountRequest.notificationURL = "http://IPNhost";

        return createAccountRequest;
    }
Ejemplo n.º 39
0
 private void ConfirmNameType(String ref1, NameType expectedResult)
 {
     NameType actualResult = CellReference.ClassifyCellReference(ref1, SpreadsheetVersion.EXCEL97);
     Assert.AreEqual(expectedResult, actualResult);
 }
 public ReflectedExtensionProperty(ExtensionPropertyInfo info, NameType nt)
     : base(new MethodInfo[] { info.Getter }, new MethodInfo[] { info.Setter }, nt) {
     _extInfo = info;
     _deleter = info.Deleter;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// 创建一个.csv文件
 /// </summary>
 /// <param name="cpath"></param>
 /// <param name="csn"></param>
 /// <param name="ctype"></param>
 public void CreateCSV(string cpath, string csn, NameType ctype = NameType.None)
 {
     Create(cpath, csn, ".csv", ctype);
 }
Ejemplo n.º 42
0
 public FlagAttribute(NameType longName = NameType.Default)
     : this(default(char), longName)
 {
     if (longName == NameType.None)
         throw new ArgumentException("Flags need at least one short or long name.");
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Sets the name field
 /// After setting all name fields you should call UpdateDisplayName
 /// </summary>
 /// <param name="strName">string to set</param>
 /// <param name="nType">NameType to set to</param>
 /// <returns>true on success</returns>
 public bool SetName(string strName, NameType nType)
 {
     return ContactSetName(pObject, strName, (int)nType);
 }
Ejemplo n.º 44
0
        public ReflectedField(FieldInfo/*!*/ info, NameType nameType) {
            Debug.Assert(info != null);

            this._nameType = nameType;
            this._info = info;
        }
Ejemplo n.º 45
0
        /**
         * Resolves a cell or area reference dynamically.
         * @param workbookName the name of the workbook Containing the reference.  If <code>null</code>
         * the current workbook is assumed.  Note - to Evaluate formulas which use multiple workbooks,
         * a {@link CollaboratingWorkbooksEnvironment} must be set up.
         * @param sheetName the name of the sheet Containing the reference.  May be <code>null</code>
         * (when <c>workbookName</c> is also null) in which case the current workbook and sheet is
         * assumed.
         * @param refStrPart1 the single cell reference or first part of the area reference.  Must not
         * be <code>null</code>.
         * @param refStrPart2 the second part of the area reference. For single cell references this
         * parameter must be <code>null</code>
         * @param isA1Style specifies the format for <c>refStrPart1</c> and <c>refStrPart2</c>.
         * Pass <c>true</c> for 'A1' style and <c>false</c> for 'R1C1' style.
         * TODO - currently POI only supports 'A1' reference style
         * @return a {@link RefEval} or {@link AreaEval}
         */

        public ValueEval GetDynamicReference(string workbookName, string sheetName, string refStrPart1,
                                             string refStrPart2, bool isA1Style)
        {
            if (!isA1Style)
            {
                throw new Exception("R1C1 style not supported yet");
            }
            SheetRefEvaluator se = CreateExternSheetRefEvaluator(workbookName, sheetName);

            if (se == null)
            {
                return(ErrorEval.REF_INVALID);
            }
            SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);

            // ugly typecast - TODO - make spReadsheet version more easily accessible
            SpreadsheetVersion ssVersion = ((IFormulaParsingWorkbook)_workbook).GetSpreadsheetVersion();

            NameType part1refType = ClassifyCellReference(refStrPart1, ssVersion);

            switch (part1refType)
            {
            case NameType.BadCellOrNamedRange:
                return(ErrorEval.REF_INVALID);

            case NameType.NamedRange:
                IEvaluationName nm = ((IFormulaParsingWorkbook)_workbook).GetName(refStrPart1, _sheetIndex);
                if (!nm.IsRange)
                {
                    throw new Exception("Specified name '" + refStrPart1 + "' is not a range as expected.");
                }
                return(_bookEvaluator.EvaluateNameFormula(nm.NameDefinition, this));
            }
            if (refStrPart2 == null)
            {
                // no ':'
                switch (part1refType)
                {
                case NameType.Column:
                case NameType.Row:
                    return(ErrorEval.REF_INVALID);

                case NameType.Cell:
                    CellReference cr = new CellReference(refStrPart1);
                    return(new LazyRefEval(cr.Row, cr.Col, sre));
                }
                throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            NameType part2refType = ClassifyCellReference(refStrPart1, ssVersion);

            switch (part2refType)
            {
            case NameType.BadCellOrNamedRange:
                return(ErrorEval.REF_INVALID);

            case NameType.NamedRange:
                throw new Exception("Cannot Evaluate '" + refStrPart1
                                    + "'. Indirect Evaluation of defined names not supported yet");
            }

            if (part2refType != part1refType)
            {
                // LHS and RHS of ':' must be compatible
                return(ErrorEval.REF_INVALID);
            }
            int firstRow, firstCol, lastRow, lastCol;

            switch (part1refType)
            {
            case NameType.Column:
                firstRow = 0;
                if (part2refType.Equals(NameType.Column))
                {
                    lastRow  = ssVersion.LastRowIndex;
                    firstCol = ParseRowRef(refStrPart1);
                    lastCol  = ParseRowRef(refStrPart2);
                }
                else
                {
                    lastRow  = ssVersion.LastRowIndex;
                    firstCol = ParseColRef(refStrPart1);
                    lastCol  = ParseColRef(refStrPart2);
                }
                break;

            case NameType.Row:
                // support of cell range in the form of integer:integer
                firstCol = 0;
                if (part2refType.Equals(NameType.Row))
                {
                    firstRow = ParseColRef(refStrPart1);
                    lastRow  = ParseColRef(refStrPart2);
                    lastCol  = ssVersion.LastColumnIndex;
                }
                else
                {
                    lastCol  = ssVersion.LastColumnIndex;
                    firstRow = ParseRowRef(refStrPart1);
                    lastRow  = ParseRowRef(refStrPart2);
                }
                break;

            case NameType.Cell:
                CellReference cr;
                cr       = new CellReference(refStrPart1);
                firstRow = cr.Row;
                firstCol = cr.Col;
                cr       = new CellReference(refStrPart2);
                lastRow  = cr.Row;
                lastCol  = cr.Col;
                break;

            default:
                throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            return(new LazyAreaEval(firstRow, firstCol, lastRow, lastCol, sre));
        }
Ejemplo n.º 46
0
        //        //??? don't like this design
        private void AddProtocolMethod(string pythonName, string methodName, NameType nameType)
        {
            if (dict.ContainsKey(SymbolTable.StringToId(pythonName)))
                return;

            object meth;
            FunctionType functionType = FunctionType.Method | FunctionType.SkipThisCheck;
            MethodInfo methodInfo = typeof(InstanceOps).GetMethod(methodName);
            if (nameType == NameType.PythonMethod) functionType |= FunctionType.PythonVisible;

            meth = BuiltinFunction.MakeMethod(pythonName, methodInfo, functionType).GetDescriptor();

            Debug.Assert(meth != null);

            dict[SymbolTable.StringToId(pythonName)] = meth;
        }
Ejemplo n.º 47
0
        internal void StoreReflectedBaseMethod(string name, MethodInfo mi, NameType nt)
        {
            object val;
            SymbolId methodId = SymbolTable.StringToId(name);
            if (dict.TryGetValue(methodId, out val)) {
                // generate a new optimized method that can handle the base class.
                BuiltinMethodDescriptor bmd = val as BuiltinMethodDescriptor;
                BuiltinFunction bf = (bmd == null) ? val as BuiltinFunction : bmd.template;

                if (bf != null) {
                    bf.AddMethod(mi);
                }
            }
        }
Ejemplo n.º 48
0
        internal void StoreReflectedMethod(string name, MethodInfo mi, NameType nt)
        {
            FunctionType ft = CompilerHelpers.IsStatic(mi) ? FunctionType.Function : FunctionType.Method;
            if (nt == NameType.PythonMethod || (!IsPythonType && !clsOnly)) ft |= FunctionType.PythonVisible;

            StoreMethod(name, mi, ft);
        }
Ejemplo n.º 49
0
        public ReflectedProperty(PropertyInfo info, MethodInfo[] getters, MethodInfo[] setters, NameType nt)
            : base(getters, setters, nt) {
            Debug.Assert(info != null);

            _info = info;
        }
        public MetaMetadata ResolveMmdName(String mmdName, NameType[] nameType)
        {
            if (mmdName == null)
                return null;
            Object resultObj = null;
            MetaMetadata result = null;
            MetaMetadataField field = mmStack.Peek();
            if (nameType != null && nameType.Length > 0)
                nameType[0] = NameType.NONE;

            // step 1: try to resolve the name as a concrete meta-metadata name, using the mmdScope.
            if (field is MetaMetadataNestedField)
            {
                MetaMetadataNestedField nested = (MetaMetadataNestedField) field;
                nested.Scope.TryGetValue(mmdName, out resultObj);
                result = (MetaMetadata) resultObj;
                if (result != null)
                    if (nameType != null && nameType.Length > 0)
                        nameType[0] = NameType.MMD;
            }

            // step 2: if step 1 failed, try to use it as a generic type var name
            if (result == null && mmdName.ToUpper().Equals(mmdName))
            {
                List<Object> gtvScopes = scopeStack.Peek().GetAll(GENERIC_TYPE_VAR_SCOPE);
                foreach (MmdGenericTypeVarScope gtvScope_object in gtvScopes)
                {
                    if (! (gtvScope_object is MmdGenericTypeVarScope))
                         throw new MetaMetadataException( "Object is not instance of MmdGenericTypeVarScope");
                    MmdGenericTypeVarScope gtvScope = gtvScope_object;

                    MmdGenericTypeVar gtv = gtvScope.Get(mmdName);
                    if (gtv != null)
                    {
                        if (gtv.Arg != null)
                            result = ResolveMmdName(gtv.Arg);
                        else if (gtv.ExtendsAttribute != null)
                            result = ResolveMmdName(gtv.ExtendsAttribute);
                        // TODO superAttribute?
                    }
                }
                if (result != null)
                    if (nameType != null && nameType.Length > 0)
                        nameType[0] = NameType.GENERIC;
            }

            return result;
        }
Ejemplo n.º 51
0
 protected ReflectedGetterSetter(ReflectedGetterSetter from) {
     _getter = from._getter;
     _setter = from._setter;
     _nameType = from._nameType;
 }
Ejemplo n.º 52
0
 public FlagAttribute(char shortName, NameType longName = NameType.Default)
     : base(longName == NameType.None ? "" : null)
 {
     _shortName = shortName;
 }
Ejemplo n.º 53
0
 public Name(NameType type, string value)
 {
     this.Type  = type;
     this.Value = value;
 }
Ejemplo n.º 54
0
        protected ReflectedGetterSetter(MethodInfo[] /*!*/ getter, MethodInfo[] /*!*/ setter, NameType nt)
        {
            Debug.Assert(getter != null);
            Debug.Assert(setter != null);

            _getter   = RemoveNullEntries(getter);
            _setter   = RemoveNullEntries(setter);
            _nameType = nt;
        }
Ejemplo n.º 55
0
        public ReflectedProperty(PropertyInfo info, MethodInfo[] getters, MethodInfo[] setters, NameType nt)
            : base(getters, setters, nt)
        {
            Debug.Assert(info != null);

            _info = info;
        }
Ejemplo n.º 56
0
 protected ReflectedGetterSetter(ReflectedGetterSetter from)
 {
     _getter   = from._getter;
     _setter   = from._setter;
     _nameType = from._nameType;
 }
Ejemplo n.º 57
0
 /// <summary>
 /// Generates a new, fully-configured phonetic engine.
 /// </summary>
 /// <param name="nameType">The type of names it will use.</param>
 /// <param name="ruleType">The type of rules it will apply.</param>
 /// <param name="concat">If it will concatenate multiple encodings.</param>
 public PhoneticEngine(NameType nameType, RuleType ruleType, bool concat)
     : this(nameType, ruleType, concat, DEFAULT_MAX_PHONEMES)
 {
 }
Ejemplo n.º 58
0
 ///<summary>Sets the value of the <c>&lt;Name&gt;</c> element.</summary>
 /// <param name="Type">Code that specifies what type of name this is.  If unsure, use 04.</param>
 /// <param name="LastName">The last name.</param>
 /// <param name="FirstName">The first name.</param>
 ///<remarks>
 /// <para>This form of <c>setName</c> is provided as a convenience method
 /// that is functionally equivalent to the <c>Name</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 1.5r1</para>
 /// </remarks>
 public void SetName(NameType Type, string LastName, string FirstName)
 {
     RemoveChild(StudentDTD.STUDENTSNAPSHOT_NAME);
     AddChild(StudentDTD.STUDENTSNAPSHOT_NAME, new Name(Type, LastName, FirstName));
 }
Ejemplo n.º 59
0
        private static List<string> ReadChildNode(XmlNode nodelist, NameType type)
        {
            List<string> actionList = new List<string>();
            if (nodelist.HasChildNodes)
            {
                XmlNodeList inputList = nodelist.ChildNodes;
                foreach (XmlNode item in inputList)
                {
                    if (type == NameType.FullName)
                    {
                        actionList.Add(getFullName(item.InnerText.ToString()));
                    }
                    else if (type == NameType.MethodName)
                    {
                        actionList.Add(getMethodName(item.InnerText.ToString()));
                    }
                    else
                    {
                        actionList.Add(item.InnerText.ToString());
                    }
                }
            }

            return actionList;
        }
Ejemplo n.º 60
0
 void prTy(NameType t, int i)
 {
     Say("NameType("); Say(t.Name.ToString()); Say(")");
 }