public void Get_name_from_option_specification()
        {
            const string ShortName = "s";
            const string LongName = "long";

            // Fixture setup
            var expected = new NameInfo(ShortName, LongName);
            var spec = new OptionSpecification(ShortName, LongName, false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '.', null, string.Empty, string.Empty, new List<string>(), typeof(IEnumerable<string>), TargetType.Sequence);

            // Exercize system
            var result = spec.FromOptionSpecification();

            // Verify outcome
            expected.ShouldBeEquivalentTo(result);

            // Teardown
        }
Beispiel #2
0
		private NameInfo DocumentToNameInfo (Document doc)
		{
			NameInfo info;
			info = new NameInfo ();

			string str;
			str = doc.Get ("Uri");
			info.Id = GuidFu.FromUriString (str);

			bool have_name = false;
			bool have_parent_id = false;
			bool have_is_dir = false;

			foreach (Field f in doc.Fields ()) {
				Property prop;
				prop = GetPropertyFromDocument (f, doc, false);
				if (prop == null)
					continue;

				switch (prop.Key) {
					
				case Property.ExactFilenamePropKey:
					info.Name = prop.Value;
					have_name = true;
					break;
					
				case Property.ParentDirUriPropKey:
					info.ParentId = GuidFu.FromUriString (prop.Value);
					have_parent_id = true;
					break;

				case Property.IsDirectoryPropKey:
					info.IsDirectory = (prop.Value == "true");
					have_is_dir = true;
					break;
				}

				if (have_name && have_parent_id && have_is_dir)
					break;
			}

			return info;
		}
Beispiel #3
0
        private ImmutableDictionary <string, EventDoc> ExtractEvents(Type type, NameInfo typeName, IncludeKind includeKind)
        {
            EventInfo[] events = type.GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

            ImmutableDictionary <string, EventDoc> dictionary = ImmutableDictionary <string, EventDoc> .Empty;

            IEnumerable <ClassInfo> classes = typeName.AsClass;

            foreach (EventInfo @event in events)
            {
                // Don't emit events that were just inherited.
                if (@event.DeclaringType != type)
                {
                    continue;
                }

                // Skip compiler-generated events, which are invisible to both
                // consumers of the assembly and to the assembly's creator.
                if (type.Name.StartsWith("<"))
                {
                    continue;
                }

                NameFlags adderFlags   = GetVisibilityNameFlags(@event.GetAddMethod());
                NameFlags removerFlags = GetVisibilityNameFlags(@event.GetRemoveMethod());

                NameFlags nameFlags = (adderFlags | removerFlags)
                                      & (NameFlags.Static | NameFlags.Abstract | NameFlags.Virtual | NameFlags.New);
                if (@event.Name.StartsWith("#"))
                {
                    nameFlags |= NameFlags.SpecialName;
                }
                else if (@event.Name.Contains("#"))
                {
                    nameFlags |= NameFlags.ExplicitInterfaceImplementation;
                }

                if (((adderFlags | removerFlags) & NameFlags.AllVisibilities) >= NameFlags.Public)
                {
                    nameFlags |= NameFlags.Public;
                }
                else if (((adderFlags | removerFlags) & NameFlags.AllVisibilities) >= NameFlags.Internal)
                {
                    nameFlags |= NameFlags.Internal;
                }
                else if (((adderFlags | removerFlags) & NameFlags.AllVisibilities) >= NameFlags.Protected)
                {
                    nameFlags |= NameFlags.Protected;
                }
                else if (((adderFlags | removerFlags) & NameFlags.AllVisibilities) >= NameFlags.Private)
                {
                    nameFlags |= NameFlags.Private;
                }

                NameInfo eventName = new NameInfo(classes, @event.Name, null, null, nameFlags);
                dictionary = dictionary.Add(@event.Name, new EventDoc(eventName,
                                                                      adderFlags: adderFlags, removerFlags: removerFlags));
            }

            return(dictionary);
        }
 internal BadFormatConversionError(NameInfo nameInfo)
     : base(ErrorType.BadFormatConversionError, nameInfo)
 {
 }
Beispiel #5
0
 public ElementDecl FindElement(Dna dna, bool brokenDna, NameInfo name, out int offset)
 {
     offset = 0;
     foreach (ElementDecl element in Elements)
     {
         if (element.NameInfo.Equals(name))
         {
             return element;
         }
         int eleLen = dna.GetElementSize(element);
         if (brokenDna)
         {
             if (element.Type.Name.Equals("short") && element.NameInfo.Name.Equals("int"))
             {
                 eleLen = 0;
             }
         }
         offset += eleLen;
     }
     return null;
 }
 private void LoadDefault()
 {
     Info = new NameInfo();
 }
	// Add an entry to the name cache.
	public NameInfo Add(String localName, String prefix, String ns)
			{
				// Intern the strings into the name table.
				String name;
				if(localName != null)
				{
					localName = nameTable.Add(localName);
				}
				else
				{
					localName = emptyString;
				}
				if(prefix != null)
				{
					prefix = nameTable.Add(prefix);
				}
				else
				{
					prefix = emptyString;
				}
				if(ns != null)
				{
					ns = nameTable.Add(ns);
				}
				else
				{
					ns = emptyString;
				}
				if(prefix.Length > 0)
				{
					name = nameTable.Add(prefix + ":" + localName);
				}
				else
				{
					name = localName;
				}

				// Search for an existing entry with this name.
				NameInfo info = (NameInfo)(this[localName]);
				NameInfo first = info;
				while(info != null)
				{
					if(((Object)(info.localName)) == ((Object)localName) &&
					   ((Object)(info.prefix)) == ((Object)prefix) &&
					   ((Object)(info.ns)) == ((Object)ns))
					{
						return info;
					}
					info = info.next;
				}

				// Add a new entry to the hash table.
				info = new NameInfo(localName, prefix, name, ns, first);
				this[localName] = info;
				return info;
			}
Beispiel #8
0
 public ElementDecl(TypeDecl type, NameInfo name)
 {
     Type = type;
     Name = name;
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        List<NameInfo> lst = new List<NameInfo>();

        try
        {
            if (name.Text.Length == 0)
            {
                message.Text = "Please provide the name to check";
                return;
            }

            string nvar = name.Text.ToLower();
            Session["name"] = nvar;
            string g = gender.SelectedValue.ToLower();
            int y = Convert.ToInt32(year.SelectedValue);

            string s = Server.MapPath("data");
            DirectoryInfo d = new DirectoryInfo(s);
            FileInfo[] fs = d.GetFiles();

            List<FileInfo> ar = new List<FileInfo>();
            foreach (FileInfo f in fs)
            {
                string fname = f.Name.ToLower();
                int yr = int.Parse(fname.Substring(fname.Length - 12, 4));

                if (yr >= y)
                {
                    if ((g == "male" || g == "female") && fname.StartsWith(g))
                        ar.Add(f);
                    else if (g == "both")
                        ar.Add(f);
                }
            }

            List<string> years = new List<string>();
            List<string> count = new List<string>();
            foreach (FileInfo ft in ar)
            {
                StreamReader sr = ft.OpenText();
                int line = 1;
                while (!sr.EndOfStream)
                {
                    string yr = ft.Name.Substring(ft.Name.Length - 12, 4);

                    string str = sr.ReadLine();
                    string[] strar = str.Split(',');
                    if (line != 1)
                    {
                        string n = strar[0].Replace("\"", "");
                        string r = strar[1].Replace("\"", "");
                        string c = strar[2].Replace("\"", "").Replace("=", "");
                        if (n.ToLower() == nvar.ToLower())
                        {
                            years.Add(yr);
                            count.Add(c);
                            NameInfo x = new NameInfo();
                            x.Year = yr;
                            x.Amount = c;
                            lst.Add(x);
                            //Response.Write(yr + "," + n + "," + r + "," + c + "<br>");
                        }

                    }
                    line++;
                }
            }
            Session["nameinfo"] = lst;
            Response.Redirect("ShowGrid.aspx");
        }
        catch (Exception ex)
        {
            Response.Write("Error : " + ex.Message);
        }
    }
Beispiel #10
0
        public object Any(SpeakerFeedRequest speakerFeedRequest)
        {
            bool       includeRestricted = UserSession.IsAuthenticated;
            const int  limit             = 50;
            XNamespace itunes            = "http://www.itunes.com/dtds/podcast-1.0.dtd";
            XNamespace atom    = "http://www.w3.org/2005/Atom";
            string     siteUrl = Request.GetApplicationUrl();

            string       logoUrl   = $"{siteUrl}/content/images/podcast_logo.png";
            const string subscribe = @"<h4>Abonner i iTunes</h4>
<ol>
	<li>Start iTunes</li>
	<li>Klikk Fil - Abonner på podcast (File - Subscribe to Podcast). (Trykk Alt-F for å få frem menyen i Windows.)
	<li>Lim inn lenken til denne siden, og klikk OK</li>
</ol>";

            using (IDbConnection db = _dbConnectionFactory.Open())
            {
                DbSpeaker speaker = null;
                if (speakerFeedRequest.Speaker != null)
                {
                    NameInfo nameInfo = speakerFeedRequest.Speaker?.ToNameInfo();
                    speaker = db.Single <DbSpeaker>(s => s.FirstName == nameInfo.FirstName && s.LastName == nameInfo.LastName && !s.Deleted);
                }

                string description = string.Empty;

                SqlExpression <DbSpeaker> query = db.From <DbSpeaker>()
                                                  .Join <DbRecordingSpeaker>((sp, recordingSpeaker) => sp.Id == recordingSpeaker.SpeakerId)
                                                  .Join <DbRecordingSpeaker, DbRecording>((recordingSpeaker, recording) =>
                                                                                          recordingSpeaker.RecordingId == recording.Id)
                                                  .Join <DbRecording, DbAlbum>((recording, album) => recording.AlbumId == album.Id)
                                                  .Where <DbRecording, DbSpeaker>((recording, sp) => !recording.Deleted && !sp.Deleted)
                                                  .Take(limit);
                if (speaker != null)
                {
                    query.And <DbSpeaker>(s => s.Id == speaker.Id);
                }
                else
                {
                    query.OrderByDescending <DbRecording>(r => r.CreatedOn);
                }

                if (!includeRestricted)
                {
                    query.And <DbRecording>(r => r.Restricted == false);
                }

                List <Tuple <DbSpeaker, DbRecordingSpeaker, DbRecording, DbAlbum> > speakerInfo =
                    db.SelectMulti <DbSpeaker, DbRecordingSpeaker, DbRecording, DbAlbum>(query);

                ILookup <long, Tuple <DbSpeaker, DbRecordingSpeaker, DbRecording, DbAlbum> > recordingLookup = speakerInfo.ToLookup(s => s.Item3.Id);

                Dictionary <long, DbAlbum> albums = speakerInfo.DistinctBy(r => r.Item4.Id).Select(r => r.Item4).ToDictionary(a => a.Id);

                IEnumerable <XElement> items =
                    from recording in speakerInfo.DistinctBy(r => r.Item3.Id).Select(r => r.Item3.ToRecording())
                    let album = albums[recording.AlbumId]
                                let speakerName = recordingLookup[recording.Id]
                                                  .Select(s => s.Item1).DistinctBy(s => s.Id)
                                                  .Select(s => s.ToSpeaker().FullName)
                                                  .ToSeparatedString('/')
                                                  let trackDescription =
                        $"{recording.Comment}{(recording.Year != null ? " ({0})".Fmt(recording.Year) : string.Empty)}".PadRight(1, '-')
                        let tagInfo = GetTag(recording)
                                      let fileInfo = _fileSystem.FileInfo.FromFileName(recording.Path)
                                                     let titleSuffix =
                            tagInfo.Tag.TrackCount > 1
                            ? " ({0}/{1})".Fmt(tagInfo.Tag.Track, tagInfo.Tag.TrackCount)
                            : string.Empty
                            let url =
                                $"{siteUrl}/Recording/Stream/{recording.Uid:N}/{fileInfo.Name.UrlEncode20()}"
                                let guid =
                                    $"{siteUrl}/Recording/Stream/{recording.Uid:N}{(speakerFeedRequest.Speaker == null ? "/top50" : string.Empty)}"
                                    select new XElement("item",
                                                        new XElement("title",
                                                                     $"{album.Name}: {recording.Title}{titleSuffix}"
                                                                     ),
                                                        new XElement(itunes + "author", speakerName
                                                                     ),
                                                        new XElement(itunes + "subtitle",
                                                                     $"{(speakerFeedRequest.Speaker == null ? $"{speakerName}: " : string.Empty)}{album.Name}"
                                                                     ),
                                                        new XElement(itunes + "summary", new XCData(trackDescription)
                                                                     ),
                                                        new XElement("description",
                                                                     $"{trackDescription}{Environment.NewLine}{subscribe}"
                                                                     ),
                                                        new XElement(itunes + "image",
                                                                     new XAttribute("href",
                                                                                    logoUrl)
                                                                     ),
                                                        new XElement("enclosure",
                                                                     new XAttribute("url", url),
                                                                     new XAttribute("length", fileInfo.Length),
                                                                     new XAttribute("type", "audio/mpeg")
                                                                     ),
                                                        new XElement("guid", guid
                                                                     ),
                                                        new XElement("pubDate", recording.CreatedOn.ToString("r")
                                                                     ),
                                                        new XElement(itunes + "duration", tagInfo.Properties.Duration.ToString(@"hh\:mm\:ss")
                                                                     ),
                                                        new XElement(itunes + "explicit", "no"
                                                                     )
                                                        );

                string title = speakerFeedRequest.Speaker ?? $"Siste {limit}";

                string link = speakerFeedRequest.Speaker != null
                                  ? $"{siteUrl}/Recording/Speaker/{speakerFeedRequest.Speaker.UrlEncode20()}"
                                  : siteUrl;

                string selfUrl = $"{siteUrl}{Request.RawUrl}";

                List <XElement> categories = new List <XElement>();
                for (int i = 0; i < Configuration.PodcastCategories.Count; i++)
                {
                    categories.Add(new XElement(itunes + "category",
                                                new XAttribute("text", Configuration.PodcastCategories[i]),
                                                new XElement(itunes + "category",
                                                             new XAttribute("text", Configuration.PodcastSubcategories[i])
                                                             )
                                                ));
                }

                XElement element =
                    new XElement("rss",
                                 new XAttribute(XNamespace.Xmlns + "itunes", "http://www.itunes.com/dtds/podcast-1.0.dtd"),
                                 new XAttribute(XNamespace.Xmlns + "atom", "http://www.w3.org/2005/Atom"),
                                 new XAttribute("version", "2.0"),
                                 new XElement("channel",
                                              new XElement(atom + "link",
                                                           new XAttribute("href", selfUrl),
                                                           new XAttribute("rel", "self"),
                                                           new XAttribute("type", "application/rss+xml"),
                                                           new XAttribute(XNamespace.Xmlns + "atom", atom)
                                                           ),
                                              new XElement("title", $"{Configuration.SiteName}: {title}"
                                                           ),
                                              new XElement("link", link
                                                           ),
                                              new XElement("language", "no"
                                                           ),
                                              new XElement("copyright", Configuration.CompanyName
                                                           ),
                                              new XElement(itunes + "subtitle", Configuration.Slogan,
                                                           new XAttribute(XNamespace.Xmlns + "itunes", itunes)
                                                           ),
                                              new XElement(itunes + "author", speakerFeedRequest.Speaker ?? Configuration.CompanyName
                                                           ),
                                              new XElement(itunes + "summary",
                                                           new XCData(WebUtility.HtmlDecode(Configuration.MetaDescription))
                                                           ),
                                              new XElement("description", description
                                                           ),
                                              new XElement(itunes + "owner",
                                                           new XElement(itunes + "name", Configuration.CompanyName
                                                                        ),
                                                           new XElement(itunes + "email", Configuration.CompanyEmail
                                                                        )
                                                           ),
                                              new XElement(itunes + "image",
                                                           new XAttribute("href", logoUrl)
                                                           ),
                                              categories,
                                              new XElement(itunes + "explicit", "no"
                                                           ),
                                              items
                                              )
                                 );

                string podcastFeed = $@"<?xml version=""1.0"" encoding=""UTF-8""?>{Environment.NewLine}{element}";
                return(new HttpResult(podcastFeed, "application/rss+xml"));
            }
        }
 private static Func <IEnumerable <SpecificationProperty>, IEnumerable <Maybe <Error> > > EnforceMutuallyExclusiveSet()
 {
     return(specProps =>
     {
         var options = specProps.Where(sp => sp.Specification.IsOption() && sp.Value.IsJust());
         var groups = options.GroupBy(g => ((OptionSpecification)g.Specification).SetName);
         if (groups.Count() > 1)
         {
             return options.Select(s => Maybe.Just <Error>(new MutuallyExclusiveSetError(NameInfo.FromOptionSpecification((OptionSpecification)s.Specification))));
         }
         return Enumerable.Empty <Nothing <Error> >();
     });
 }
Beispiel #12
0
 public ElementDecl(TypeDecl type, NameInfo nameInfo)
 {
     Type     = type;
     NameInfo = nameInfo;
 }
Beispiel #13
0
        public void Init(BinaryReader reader, bool swap)
        {
            Stream stream = reader.BaseStream;

            // SDNA
            byte[] code  = reader.ReadBytes(8);
            string codes = ASCIIEncoding.ASCII.GetString(code);

            // NAME
            if (!codes.Equals("SDNANAME"))
            {
                throw new InvalidDataException();
            }
            int dataLen = reader.ReadInt32();

            _names = new NameInfo[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List <byte> name = new List <byte>();
                byte        ch   = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }

                _names[i] = new NameInfo(ASCIIEncoding.ASCII.GetString(name.ToArray()));
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TYPE
            code  = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TYPE"))
            {
                throw new InvalidDataException();
            }
            dataLen = reader.ReadInt32();
            _types  = new TypeDecl[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List <byte> name = new List <byte>();
                byte        ch   = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }
                string type = ASCIIEncoding.ASCII.GetString(name.ToArray());
                _types[i] = new TypeDecl(type);
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TLEN
            code  = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TLEN"))
            {
                throw new InvalidDataException();
            }
            for (int i = 0; i < _types.Length; i++)
            {
                _types[i].Length = reader.ReadInt16();
            }
            stream.Position = (stream.Position + 3) & ~3;

            // STRC
            code  = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("STRC"))
            {
                throw new InvalidDataException();
            }
            dataLen  = reader.ReadInt32();
            _structs = new StructDecl[dataLen];
            // NU long shtPtr = stream.Position;
            for (int i = 0; i < dataLen; i++)
            {
                StructDecl structDecl = new StructDecl();
                _structs[i] = structDecl;
                if (swap)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    short typeNr = reader.ReadInt16();
                    structDecl.Type        = _types[typeNr];
                    structDecl.Type.Struct = structDecl;
                    int numElements = reader.ReadInt16();
                    structDecl.Elements = new ElementDecl[numElements];
                    for (int j = 0; j < numElements; j++)
                    {
                        typeNr = reader.ReadInt16();
                        short nameNr = reader.ReadInt16();
                        structDecl.Elements[j] = new ElementDecl(_types[typeNr], _names[nameNr]);
                    }
                }
            }

            // build reverse lookups
            _structReverse = new Dictionary <string, int>(_structs.Length);
            for (int i = 0; i < _structs.Length; i++)
            {
                StructDecl s = _structs[i];
                if (_ptrLen == 0 && s.Type.Name.Equals("ListBase"))
                {
                    _ptrLen = s.Type.Length / 2;
                }
                _structReverse.Add(s.Type.Name, i);
            }
        }
Beispiel #14
0
 public ElementDecl(TypeDecl type, NameInfo name)
 {
     Type = type;
     Name = name;
 }
        public override INameInfo GetName(string worksheet, string name)
        {
            ExcelNamedRange nameItem;
            ulong           id;
            ExcelWorksheet  ws;

            if (string.IsNullOrEmpty(worksheet))
            {
                if (_package._workbook.Names.ContainsKey(name))
                {
                    nameItem = _package._workbook.Names[name];
                }
                else
                {
                    return(null);
                }
                ws = null;
            }
            else
            {
                ws = _package._workbook.Worksheets[worksheet];
                if (ws != null && ws.Names.ContainsKey(name))
                {
                    nameItem = ws.Names[name];
                }
                else if (_package._workbook.Names.ContainsKey(name))
                {
                    nameItem = _package._workbook.Names[name];
                }
                else
                {
                    var wsName = _package.Workbook.Worksheets[name];
                    if (wsName == null)
                    {
                        return(null);
                    }
                    nameItem = new ExcelNamedRange(name, ws, wsName, "A:XFD", -1);
                }
            }
            id = ExcelAddressBase.GetCellID(nameItem.LocalSheetId, nameItem.Index, 0);

            if (_names.ContainsKey(id))
            {
                return(_names[id]);
            }
            else
            {
                var ni = new NameInfo()
                {
                    Id        = id,
                    Name      = name,
                    Worksheet = string.IsNullOrEmpty(worksheet) ? (nameItem.Worksheet == null ? nameItem._ws : nameItem.Worksheet.Name) : worksheet,
                    Formula   = nameItem.Formula
                };
                if (nameItem._fromRow > 0)
                {
                    ni.Value = new RangeInfo(nameItem.Worksheet ?? ws, nameItem._fromRow, nameItem._fromCol, nameItem._toRow, nameItem._toCol);
                }
                else
                {
                    ni.Value = nameItem.Value;
                }
                _names.Add(id, ni);
                return(ni);
            }
        }
Beispiel #16
0
        private ImmutableDictionary <string, MethodDoc> ExtractConstructors(Type type, NameInfo typeName, IncludeKind includeKind)
        {
            ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

            ImmutableDictionary <string, MethodDoc> dictionary = ImmutableDictionary <string, MethodDoc> .Empty;

            IEnumerable <ClassInfo> classes = typeName.AsClass;

            foreach (ConstructorInfo constructor in constructors)
            {
                // Don't emit constructors that were just inherited.
                if (constructor.DeclaringType != type)
                {
                    continue;
                }

                // Skip compiler-generated constructors, which are invisible to both
                // consumers of the assembly and to the assembly's creator.
                if (constructor.Name.StartsWith("<"))
                {
                    continue;
                }

                NameFlags nameFlags = GetVisibilityNameFlags(constructor);

                List <TypeParameterDoc> typeParameters = null;

                string effectiveMethodName = constructor.Name;
                int    backtickIndex       = effectiveMethodName.IndexOf('`');
                if (backtickIndex >= 0)
                {
                    effectiveMethodName = effectiveMethodName.Substring(0, backtickIndex);
                }

                List <Tuple <ParamInfo, ParameterDoc> > parameters = GetParameters(constructor.GetParameters());

                NameInfo methodName = new NameInfo(classes, effectiveMethodName,
                                                   typeParameters?.Select(t => t.Name),
                                                   parameters.Select(p => p.Item1),
                                                   nameFlags);

                List <ParameterDoc> parameterDocs = parameters.Select(p => p.Item2).ToList();

                dictionary = dictionary.Add(methodName.NameWithParameters,
                                            new MethodDoc(methodName, null, typeParameters, parameterDocs, null));
            }

            return(dictionary);
        }
Beispiel #17
0
        private ImmutableDictionary <string, PropertyDoc> ExtractProperties(Type type, NameInfo typeName, IncludeKind includeKind)
        {
            PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

            ImmutableDictionary <string, PropertyDoc> dictionary = ImmutableDictionary <string, PropertyDoc> .Empty;

            IEnumerable <ClassInfo> classes = typeName.AsClass;

            foreach (PropertyInfo property in properties)
            {
                // Don't emit properties that were just inherited.
                if (property.DeclaringType != type)
                {
                    continue;
                }

                // Skip compiler-generated properties, which are invisible to both
                // consumers of the assembly and to the assembly's creator.
                if (type.Name.StartsWith("<"))
                {
                    continue;
                }

                NameFlags getterFlags = GetVisibilityNameFlags(property.GetGetMethod());
                NameFlags setterFlags = GetVisibilityNameFlags(property.GetSetMethod());

                NameFlags nameFlags = (getterFlags | setterFlags)
                                      & (NameFlags.Static | NameFlags.Abstract | NameFlags.Virtual | NameFlags.New);
                if (property.Name.StartsWith("#"))
                {
                    nameFlags |= NameFlags.SpecialName;
                }
                else if (property.Name.Contains("#"))
                {
                    nameFlags |= NameFlags.ExplicitInterfaceImplementation;
                }

                if (((getterFlags | setterFlags) & NameFlags.AllVisibilities) >= NameFlags.Public)
                {
                    nameFlags |= NameFlags.Public;
                }
                else if (((getterFlags | setterFlags) & NameFlags.AllVisibilities) >= NameFlags.Internal)
                {
                    nameFlags |= NameFlags.Internal;
                }
                else if (((getterFlags | setterFlags) & NameFlags.AllVisibilities) >= NameFlags.Protected)
                {
                    nameFlags |= NameFlags.Protected;
                }
                else if (((getterFlags | setterFlags) & NameFlags.AllVisibilities) >= NameFlags.Private)
                {
                    nameFlags |= NameFlags.Private;
                }

                NameInfo propertyName = new NameInfo(classes, property.Name, null, null, nameFlags);
                dictionary = dictionary.Add(property.Name, new PropertyDoc(propertyName,
                                                                           getterFlags: getterFlags, setterFlags: setterFlags));
            }

            return(dictionary);
        }
Beispiel #18
0
            public override void ExecuteSimple()
            {
                // extract domain object
                var domainObject = arguments.DomainObject;

                //
                if (domainObject == null)
                {
                    return;
                }
                //
                /// Get the Info Factory services from the Core System
                INameInfoFactory    nameInfoFactory    = CoreSystem.GetService <INameInfoFactory>(domainObject);
                IColorInfoFactory   colorInfoFactory   = CoreSystem.GetService <IColorInfoFactory>(domainObject);
                ICommentInfoFactory commentInfoFactory = CoreSystem.GetService <ICommentInfoFactory>(domainObject);

                if (nameInfoFactory != null && colorInfoFactory != null && commentInfoFactory != null)
                {
                    NameInfo    nameInfo    = nameInfoFactory.GetNameInfo(domainObject);
                    ColorInfo   colorInfo   = colorInfoFactory.GetColorInfo(domainObject);
                    CommentInfo commentInfo = commentInfoFactory.GetCommentInfo(domainObject);

                    if (nameInfo != null && colorInfo != null && commentInfo != null)
                    {
                        /// Print the Borehole Domain objects settings data.
                        PetrelLogger.InfoOutputWindow(Environment.NewLine);
                        PetrelLogger.InfoOutputWindow("Settings Info Data Access for    : " + domainObject.GetType().Name);
                        PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------");
                        PetrelLogger.InfoOutputWindow(" Name                    : " + nameInfo.Name);
                        PetrelLogger.InfoOutputWindow(" Color                   : " + colorInfo.Color.ToString());
                        PetrelLogger.InfoOutputWindow(" TypeName                : " + nameInfo.TypeName);
                        PetrelLogger.InfoOutputWindow(" Comments                : " + commentInfo.Comment);
                        PetrelLogger.InfoOutputWindow(" Can change the Name     : " + nameInfo.CanChangeName.ToString());
                    }
                }

                IHistoryInfoEditor borholeHistoryEditor = HistoryService.GetHistoryInfoEditor(domainObject);

                if (borholeHistoryEditor != null)
                {
                    PetrelLogger.InfoOutputWindow(Environment.NewLine);
                    PetrelLogger.InfoOutputWindow("History Data Access for  : " + domainObject.GetType().Name);
                    PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------");

                    /// add an History Entry
                    HistoryEntry testHistoryEntry = new HistoryEntry(DateTime.Now, DateTime.Now, Environment.UserName, "Test", "Test Arguments", "Test Version");
                    borholeHistoryEditor.AddHistoryEntry(testHistoryEntry);

                    /// Update the last history record
                    borholeHistoryEditor.UpdateLastHistoryEntry(Environment.UserName, "Test", "Test Arguments", "Test Version");

                    /// access to old history
                    foreach (HistoryEntry entry in borholeHistoryEditor.History)
                    {
                        PetrelLogger.InfoOutputWindow(" User Name               : " + entry.UserName);
                        PetrelLogger.InfoOutputWindow(" Operation               : " + entry.Operation);
                        PetrelLogger.InfoOutputWindow(" Arguments               : " + entry.Arguments);
                        PetrelLogger.InfoOutputWindow(" AppVersion              : " + entry.AppVersion);
                        PetrelLogger.InfoOutputWindow(" Begin Date              : " + entry.BeginDate.ToString());
                        PetrelLogger.InfoOutputWindow(" End Date                : " + entry.EndDate.ToString());
                        PetrelLogger.InfoOutputWindow(Environment.NewLine);
                    }
                }


                //Type type = typeof(argumentPackage.Borehole);
                if (StatisticsService.CanGetStatistics(domainObject.GetType()))
                {
                    Statistics stats = StatisticsService.GetStatistics(domainObject);
                    if (stats != null)
                    {
                        PetrelLogger.InfoOutputWindow("Statistics Data Access for   : " + domainObject.GetType().Name);
                        PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------");
                        PetrelLogger.InfoOutputWindow(Environment.NewLine);

                        PetrelLogger.InfoOutputWindow("Axis Info items : ");
                        PetrelLogger.InfoOutputWindow(Environment.NewLine);
                        foreach (AxisInfoItem axis in stats.AxisInfo)
                        {
                            PetrelLogger.InfoOutputWindow(" Axis Name               : " + axis.Name);
                            PetrelLogger.InfoOutputWindow(" Axis Min Value          : " + axis.Min);
                            PetrelLogger.InfoOutputWindow(" Axis Max Value          : " + axis.Max);
                            PetrelLogger.InfoOutputWindow(" Axis Delta Value        : " + axis.Delta);
                            PetrelLogger.InfoOutputWindow(" Axis UnitMeasurement    : " + axis.UnitMeasurement.ToString());
                            PetrelLogger.InfoOutputWindow(Environment.NewLine);
                        }

                        PetrelLogger.InfoOutputWindow("Key Value Pair items : ");
                        PetrelLogger.InfoOutputWindow(Environment.NewLine);
                        foreach (KeyValuePair <string, string> keypair in stats.Attributes)
                        {
                            PetrelLogger.InfoOutputWindow(" Key                     : " + keypair.Key);
                            PetrelLogger.InfoOutputWindow(" Value                   : " + keypair.Value);
                            PetrelLogger.InfoOutputWindow(Environment.NewLine);
                        }
                    }
                }
            }
Beispiel #19
0
        public void Init(BinaryReader reader, bool swap)
        {
            Stream stream = reader.BaseStream;

            // SDNA
            byte[] code = reader.ReadBytes(8);
            string codes = ASCIIEncoding.ASCII.GetString(code);

            // NAME
            if (!codes.Equals("SDNANAME"))
            {
                throw new InvalidDataException();
            }
            int dataLen = reader.ReadInt32();
            _names = new NameInfo[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List<byte> name = new List<byte>();
                byte ch = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }

                _names[i] = new NameInfo(ASCIIEncoding.ASCII.GetString(name.ToArray()));
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TYPE
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TYPE"))
            {
                throw new InvalidDataException();
            }
            dataLen = reader.ReadInt32();
            _types = new TypeDecl[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List<byte> name = new List<byte>();
                byte ch = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }
                string type = ASCIIEncoding.ASCII.GetString(name.ToArray());
                _types[i] = new TypeDecl(type);
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TLEN
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TLEN"))
            {
                throw new InvalidDataException();
            }
            for (int i = 0; i < _types.Length; i++)
            {
                _types[i].Length = reader.ReadInt16();
            }
            stream.Position = (stream.Position + 3) & ~3;

            // STRC
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("STRC"))
            {
                throw new InvalidDataException();
            }
            dataLen = reader.ReadInt32();
            _structs = new StructDecl[dataLen];
            long shtPtr = stream.Position;
            for (int i = 0; i < dataLen; i++)
            {
                StructDecl structDecl = new StructDecl();
                _structs[i] = structDecl;
                if (swap)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    short typeNr = reader.ReadInt16();
                    structDecl.Type = _types[typeNr];
                    structDecl.Type.Struct = structDecl;
                    int numElements = reader.ReadInt16();
                    structDecl.Elements = new ElementDecl[numElements];
                    for (int j = 0; j < numElements; j++)
                    {
                        typeNr = reader.ReadInt16();
                        short nameNr = reader.ReadInt16();
                        structDecl.Elements[j] = new ElementDecl(_types[typeNr], _names[nameNr]);
                    }
                }
            }

            // build reverse lookups
            _structReverse = new Dictionary<string, int>(_structs.Length);
            for (int i = 0; i < _structs.Length; i++)
            {
                StructDecl s = _structs[i];
                if (_ptrLen == 0 && s.Type.Name.Equals("ListBase"))
                {
                    _ptrLen = s.Type.Length / 2;
                }
                _structReverse.Add(s.Type.Name, i);
            }
        }
Beispiel #20
0
 public override int Compare(NameInfo other)
 {
     return(this.Compare(other.name, other.tags));
 }
		// Constructor.
		public NameInfo(String localName, String prefix,
						String name, String ns, NameInfo next)
			{
				this.localName = localName;
				this.prefix = prefix;
				this.name = name;
				this.ns = ns;
				this.next = next;
			}
Beispiel #22
0
 public ElementDecl(TypeDecl type, NameInfo nameInfo)
 {
     Type = type;
     NameInfo = nameInfo;
 }
        public override INameInfo GetName(string worksheet, string name)
        {
            ExcelNamedRange nameItem;
            ulong id;            
            ExcelWorksheet ws;
            if (string.IsNullOrEmpty(worksheet))
            {
                if(_package._workbook.Names.ContainsKey(name))
                {
                    nameItem = _package._workbook.Names[name];
                }
                else
                {
                    return null;
                }
                ws = null;
            }
            else
            {
                ws = _package._workbook.Worksheets[worksheet];
                if (ws !=null && ws.Names.ContainsKey(name))
                {
                    nameItem = ws.Names[name];
                }
                else if (_package._workbook.Names.ContainsKey(name))
                {
                    nameItem = _package._workbook.Names[name];
                }
                else
                {
                    return null;
                }
            }
            id = ExcelAddressBase.GetCellID(nameItem.LocalSheetId, nameItem.Index, 0);

            if (_names.ContainsKey(id))
            {
                return _names[id];
            }
            else
            {
                var ni = new NameInfo()
                {
                    Id = id,
                    Name = name,
                    Worksheet = nameItem.Worksheet==null ? nameItem._ws : nameItem.Worksheet.Name, 
                    Formula = nameItem.Formula
                };
                if (nameItem._fromRow > 0)
                {
                    ni.Value = new RangeInfo(nameItem.Worksheet ?? ws, nameItem._fromRow, nameItem._fromCol, nameItem._toRow, nameItem._toCol);
                }
                else
                {
                    ni.Value = nameItem.Value;
                }
                _names.Add(id, ni);
                return ni;
            }
        }
Beispiel #24
0
 public string TestRSA(string content, NameInfo number)
 {
     return(content + ",age:" + number.age + " " + this.Session["name"]);
 }