private vCard requestVCard(SID sid) {
			ensureLoggedIn();

			var getResponse = WebSession.Get(string.Format("https://intranet.avegagroup.se/templates/vcard.aspx?SID={0}&ext=.vcf", sid.Value));

			using (var stream = new StringReader(getResponse.TextContent)) {
				vCard card = new vCard(stream);
				return card;
			}

		}
		private byte[] requestImage(SID sid) {
			ensureLoggedIn();

			var getResponse = WebSession.Get(string.Format("https://intranet.avegagroup.se/templates/UserDetails.aspx?id=1105&SID={0}", sid.Value));

			var contentHtml = getResponse.TextContent;
			HtmlTagReader tagReader = new HtmlTagReader(contentHtml, "img");

			while (tagReader.GetNextTag()) {
				var hrefValue = HtmlTagReader.GetAttributeValueInTag(tagReader.CurrentTag.Content, "src");

				if (hrefValue != null && hrefValue.Contains("/upload/Medarbetarbilder/")) {
					var imgResponse = WebSession.Get("https://intranet.avegagroup.se" + hrefValue);

					return imgResponse.RawResponse;
				}						
			}
			return null;
		}
Beispiel #3
0
        private void LoadENTControls(object[] entArray)
        {
            this.selectedTagType = Maps.map[mapIndex].SelectedMeta.type;

            this.toolStripTagType.Text = "[" + this.selectedTagType.ToString() + "]";
            this.toolStripTagName.Text = Maps.map[mapIndex].SelectedMeta.name;
            //this.Padding = new Padding(10);
            int colorSpaceCount = 4;

            // Custom Plugins access
            ra = new RegistryAccess(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2CustomPlugins + pluginName + "\\" + this.selectedTagType);
            if (pluginName == null)
            {
                ra.CloseReg();
            }

            foreach (object o in entArray)
            {
                IFPIO.BaseObject tempbase = (IFPIO.BaseObject)o;
                if (tempbase.visible == false)
                {
                    if (Meta_Editor.MetaEditor.ShowInvisibles == false)
                    {
                        continue;
                    }
                }

                // skip hidden custom plugins variables (mark reflexives to be removed if empty)
                bool skipEmptyReflex = false;
                if (ra.isOpen && ra.getValue(tempbase.offset.ToString()) == bool.FalseString)
                {
                    if (tempbase.ObjectType == IFPIO.ObjectEnum.Struct)
                    {
                        skipEmptyReflex = true;
                    }
                    else
                    {
                        continue;
                    }
                }


                switch (tempbase.ObjectType)
                {
                case IFPIO.ObjectEnum.Struct:
                {
                    if (Meta_Editor.MetaEditor.ShowReflexives == false)
                    {
                        break;
                    }
                    // tempLabel is a blank space located above reflexives
                    Label tempLabel = new Label();
                    tempLabel.AutoSize = true;
                    tempLabel.Location = new System.Drawing.Point(0, 0);
                    tempLabel.Name     = "label1";
                    tempLabel.Dock     = DockStyle.Top;
                    tempLabel.Size     = new System.Drawing.Size(35, 13);
                    tempLabel.TabIndex = tabIndex;

                    // tempReflexive is the reflexive and all data (incl other reflexives) within it
                    ReflexiveControl tempReflexive = new ReflexiveControl(mapIndex, Maps.map[mapIndex].SelectedMeta.offset, ((IFPIO.Reflexive)tempbase).HasCount, tempbase.lineNumber, this);
                    //tempReflexive.Location = new System.Drawing.Point(10, 0);
                    tempReflexive.Name     = "reflexive";
                    tempReflexive.TabIndex = tabIndex;
                    tempReflexive.LoadENTControls((IFPIO.Reflexive)tempbase, ((IFPIO.Reflexive)tempbase).items,
                                                  true, 0, ref tabIndex, tempbase.offset.ToString());

                    // Label, Combobox & Button are always added ( = 3)
                    if (!(tempReflexive.Controls.Count <= 2 && skipEmptyReflex))
                    {
                        this.Controls[0].Controls.Add(tempLabel);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                        this.Controls[0].Controls.Add(tempReflexive);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    }
                    break;
                }

                case IFPIO.ObjectEnum.Ident:
                {
                    if (Meta_Editor.MetaEditor.ShowIdents == false)
                    {
                        break;
                    }
                    Ident tempident = new Ident(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.Ident)tempbase).hasTagType, tempbase.lineNumber);
                    tempident.Name     = "ident";
                    tempident.TabIndex = tabIndex;
                    tempident.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    tempident.Tag = "[" + tempident.Controls[2].Text + "] "
                                    + tempident.Controls[1].Text;
                    tempident.Controls[1].ContextMenuStrip = identContext;
                    this.Controls[0].Controls.Add(tempident);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.StringID:
                {
                    if (Meta_Editor.MetaEditor.ShowSIDs == false)
                    {
                        break;
                    }
                    SID tempSID = new SID(tempbase.name, mapIndex, tempbase.offset, tempbase.lineNumber);
                    tempSID.Name     = "sid";
                    tempSID.TabIndex = tabIndex;
                    tempSID.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempSID);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Float:
                {
                    if (Meta_Editor.MetaEditor.ShowFloats == false)
                    {
                        break;
                    }
                    DataValues tempFloat = new DataValues(tempbase.name, mapIndex, tempbase.offset, IFPIO.ObjectEnum.Float, tempbase.lineNumber);
                    tempFloat.TabIndex = tabIndex;
                    tempFloat.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempFloat);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.String32:
                {
                    if (Meta_Editor.MetaEditor.ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                    {
                        break;
                    }
                    EntStrings tempstring = new EntStrings(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.IFPString)tempbase).size, ((IFPIO.IFPString)tempbase).type, tempbase.lineNumber);
                    tempstring.Name     = "string";
                    tempstring.TabIndex = tabIndex;
                    tempstring.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempstring);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.UnicodeString256:
                {
                    if (Meta_Editor.MetaEditor.ShowUnicodeString256s == false)
                    {
                        break;
                    }
                    goto case IFPIO.ObjectEnum.String32;
                }

                case IFPIO.ObjectEnum.String256:
                {
                    if (Meta_Editor.MetaEditor.ShowString256s == false)
                    {
                        break;
                    }
                    goto case IFPIO.ObjectEnum.String32;
                }

                case IFPIO.ObjectEnum.UnicodeString64:
                {
                    if (Meta_Editor.MetaEditor.ShowUnicodeString64s == false)
                    {
                        break;
                    }
                    goto case IFPIO.ObjectEnum.String32;
                }

                case IFPIO.ObjectEnum.String:
                {
                    if (Meta_Editor.MetaEditor.ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                    {
                        break;
                    }
                    EntStrings tempstring = new EntStrings(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.IFPString)tempbase).size, ((IFPIO.IFPString)tempbase).type, tempbase.lineNumber);
                    tempstring.Name     = "string";
                    tempstring.TabIndex = tabIndex;
                    tempstring.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempstring);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Int:
                {
                    if (((IFPIO.IFPInt)tempbase).entIndex.nulled == true)
                    {
                        if ((Meta_Editor.MetaEditor.ShowInts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Int) ||
                            (Meta_Editor.MetaEditor.ShowShorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Short) ||
                            (Meta_Editor.MetaEditor.ShowUshorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.UShort) ||
                            (Meta_Editor.MetaEditor.ShowUints == false && tempbase.ObjectType == IFPIO.ObjectEnum.UInt))
                        {
                            break;
                        }
                        DataValues tempdatavalues = new DataValues(tempbase.name, mapIndex, tempbase.offset, tempbase.ObjectType, tempbase.lineNumber);
                        tempdatavalues.TabIndex = tabIndex;
                        tempdatavalues.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                        this.Controls[0].Controls.Add(tempdatavalues);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    }
                    else
                    {
                        if ((Meta_Editor.MetaEditor.ShowBlockIndex32s == false && (tempbase.ObjectType == IFPIO.ObjectEnum.Int | tempbase.ObjectType == IFPIO.ObjectEnum.UInt)) ||
                            (Meta_Editor.MetaEditor.ShowBlockIndex16s == false && (tempbase.ObjectType == IFPIO.ObjectEnum.Short | tempbase.ObjectType == IFPIO.ObjectEnum.UShort)) ||
                            (Meta_Editor.MetaEditor.ShowBlockIndex8s == false && tempbase.ObjectType == IFPIO.ObjectEnum.Byte))
                        {
                            break;
                        }
                        Indices tempdatavalues = new Indices(tempbase.name, mapIndex, tempbase.offset, tempbase.ObjectType, ((IFPIO.IFPInt)tempbase).entIndex);
                        tempdatavalues.TabIndex = tabIndex;
                        this.Controls[0].Controls.Add(tempdatavalues);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    }
                    break;
                }

                case IFPIO.ObjectEnum.Short:
                {
                    goto case IFPIO.ObjectEnum.Int;
                }

                case IFPIO.ObjectEnum.UShort:
                {
                    goto case IFPIO.ObjectEnum.Int;
                }

                case IFPIO.ObjectEnum.UInt:
                {
                    goto case IFPIO.ObjectEnum.Int;
                }

                case IFPIO.ObjectEnum.Unknown:
                {
                    if (Meta_Editor.MetaEditor.ShowUndefineds == false)
                    {
                        break;
                    }
                    DataValues tempUnknown = new DataValues(tempbase.name, mapIndex, tempbase.offset, IFPIO.ObjectEnum.Unknown, tempbase.lineNumber);
                    tempUnknown.TabIndex = tabIndex;
                    tempUnknown.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempUnknown);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Byte_Flags:
                {
                    if (Meta_Editor.MetaEditor.ShowBitmask8s == false)
                    {
                        break;
                    }
                    Bitmask tempbitmask = new Bitmask(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.Bitmask)tempbase).bitmaskSize, ((IFPIO.Bitmask)tempbase).options, tempbase.lineNumber);
                    tempbitmask.TabIndex = tabIndex;
                    tempbitmask.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempbitmask);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Word_Flags:
                {
                    if (Meta_Editor.MetaEditor.ShowBitmask16s == false)
                    {
                        break;
                    }
                    Bitmask tempbitmask = new Bitmask(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.Bitmask)tempbase).bitmaskSize, ((IFPIO.Bitmask)tempbase).options, tempbase.lineNumber);
                    tempbitmask.TabIndex = tabIndex;
                    tempbitmask.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempbitmask);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Long_Flags:
                {
                    if (Meta_Editor.MetaEditor.ShowBitmask32s == false)
                    {
                        break;
                    }
                    Bitmask tempbitmask = new Bitmask(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.Bitmask)tempbase).bitmaskSize, ((IFPIO.Bitmask)tempbase).options, tempbase.lineNumber);
                    tempbitmask.TabIndex = tabIndex;
                    tempbitmask.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempbitmask);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Char_Enum:
                {
                    if (Meta_Editor.MetaEditor.ShowEnum8s == false)
                    {
                        break;
                    }
                    Enums tempenum = new Enums(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.IFPEnum)tempbase).enumSize, ((IFPIO.IFPEnum)tempbase).options, tempbase.lineNumber);
                    tempenum.TabIndex = tabIndex;
                    tempenum.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempenum);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Enum:
                {
                    if (Meta_Editor.MetaEditor.ShowEnum16s == false)
                    {
                        break;
                    }
                    Enums tempenum = new Enums(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.IFPEnum)tempbase).enumSize, ((IFPIO.IFPEnum)tempbase).options, tempbase.lineNumber);
                    tempenum.TabIndex = tabIndex;
                    tempenum.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempenum);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Long_Enum:
                {
                    if (Meta_Editor.MetaEditor.ShowEnum32s == false)
                    {
                        break;
                    }
                    Enums tempenum = new Enums(tempbase.name, mapIndex, tempbase.offset, ((IFPIO.IFPEnum)tempbase).enumSize, ((IFPIO.IFPEnum)tempbase).options, tempbase.lineNumber);
                    tempenum.TabIndex = tabIndex;
                    tempenum.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempenum);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.Byte:
                {
                    if (((IFPIO.IFPByte)tempbase).entIndex.nulled == true)
                    {
                        if (Meta_Editor.MetaEditor.ShowBytes == false)
                        {
                            break;
                        }
                        DataValues tempByte = new DataValues(tempbase.name, mapIndex, tempbase.offset, IFPIO.ObjectEnum.Byte, tempbase.lineNumber);
                        tempByte.TabIndex = tabIndex;
                        this.Controls[0].Controls.Add(tempByte);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    }
                    else
                    {
                        if (Meta_Editor.MetaEditor.ShowBlockIndex8s == false)
                        {
                            break;
                        }
                        Indices tempdatavalues = new Indices(tempbase.name, mapIndex, tempbase.offset, tempbase.ObjectType, ((IFPIO.IFPByte)tempbase).entIndex);
                        tempdatavalues.TabIndex = tabIndex;
                        this.Controls[0].Controls.Add(tempdatavalues);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    }
                    break;
                }

                case IFPIO.ObjectEnum.Unused:
                {
                    DataValues tempUnknown = new DataValues(tempbase.name, mapIndex, tempbase.offset, IFPIO.ObjectEnum.Unused, tempbase.lineNumber);
                    tempUnknown.TabIndex = tabIndex;
                    tempUnknown.Populate(Maps.map[mapIndex].SelectedMeta.offset);
                    this.Controls[0].Controls.Add(tempUnknown);
                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                    break;
                }

                case IFPIO.ObjectEnum.TagType:
                    continue;
                    break;
                }

                if (!(tempbase is IFPIO.Reflexive))
                {
                    ToolTip1.SetToolTip(this.Controls[0].Controls[0].Controls[0], "offset: " + tempbase.offset.ToString());
                }

                if (this.Controls[0].Controls.Count > 0 && this.Controls[0].Controls[0] is DataValues)
                {
                    //if (((tempbase.name.ToLower().Contains(" a") & tempbase.name[tempbase.name.ToLower().IndexOf(" a")]) ||
                    //     tempbase.name.ToLower().Contains("alpha"))& alphaControl == null)
                    if (ColorWheel.checkForColor(tempbase.name, alphaControl, " a", "alpha"))
                    {
                        alphaControl    = (DataValues)this.Controls[0].Controls[0];
                        colorSpaceCount = 0;
                    }
                    //if (tempbase.name.ToLower().Contains(" r") & redControl == null)
                    else if (ColorWheel.checkForColor(tempbase.name, redControl, " r", "red"))
                    {
                        redControl      = (DataValues)this.Controls[0].Controls[0];
                        colorSpaceCount = 0;
                    }
                    //if (tempbase.name.ToLower().Contains(" g") & greenControl == null)
                    else if (ColorWheel.checkForColor(tempbase.name, greenControl, " g", "green"))
                    {
                        greenControl    = (DataValues)this.Controls[0].Controls[0];
                        colorSpaceCount = 0;
                    }
                    //if (tempbase.name.ToLower().Contains(" b") & blueControl == null)
                    else if (ColorWheel.checkForColor(tempbase.name, blueControl, " b", "blue"))
                    {
                        blueControl     = (DataValues)this.Controls[0].Controls[0];
                        colorSpaceCount = 0;
                    }
                    else
                    {
                        colorSpaceCount++;
                        if (colorSpaceCount == 1)
                        {
                            alphaControl = null;
                            redControl   = null;
                            greenControl = null;
                            blueControl  = null;
                        }
                    }
                    if (redControl != null & greenControl != null & blueControl != null)
                    {
                        // Create the new ColorWheel class, indicating
                        // the locations of the color wheel itself, the
                        // brightness area, and the position of the selected color.
                        ColorWheel cw = new ColorWheel();

                        if (alphaControl != null)
                        {
                            cw.setTextBox(alphaControl.textBox1, Color.White);
                        }
                        cw.setTextBox(redControl.textBox1, Color.Red);
                        cw.setTextBox(greenControl.textBox1, Color.Green);
                        cw.setTextBox(blueControl.textBox1, Color.Blue);

                        //p.I.AddRange(new Rectangle[] { SelectedColorRectangle });
                        cw.Dock = DockStyle.Top;
                        this.Controls[0].Controls.Add(cw);
                        this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                        // Reset for next batch
                        colorSpaceCount++;
                        alphaControl = null;
                        redControl   = null;
                        greenControl = null;
                        blueControl  = null;
                    }
                }
                else
                {
                    colorSpaceCount++;
                }
                tabIndex++;
            }
            ra.CloseReg();
        }
 /// <summary>
 /// Returns true if the given SID is the specified "well known" SID type.
 /// </summary>
 public static bool IsWellKnownSid(ref SID sid, WELL_KNOWN_SID_TYPE sidType)
 {
     return(Imports.IsWellKnownSid(ref sid, sidType));
 }
 /// <summary>
 /// Returns true if the given SID is valid.
 /// </summary>
 public static bool IsValidSid(ref SID sid)
 {
     return(Imports.IsValidSid(ref sid));
 }
Beispiel #6
0
        /// <summary>
        /// Perform startup configuration of a service instance.
        /// </summary>
        /// <remarks>
        /// Should not be manually invoked and should only be overridden if <see cref="Start(MindTouch.Xml.XDoc,Autofac.ILifetimeScope,MindTouch.Tasking.Result)"/> isn't already overriden.
        /// </remarks>
        /// <param name="config">Service configuration.</param>
        /// <param name="result">Synchronization handle for coroutine invocation.</param>
        /// <returns>Iterator used by <see cref="Coroutine"/> execution environment.</returns>
        protected virtual Yield Start(XDoc config, Result result)
        {
            Result <DreamMessage> res;

            // store configuration and uri
            _config = config;
            _self   = Plug.New(config["uri.self"].AsUri);
            if (_self == null)
            {
                throw new ArgumentNullException("config", "Missing element'uri.self'");
            }
            _owner = Plug.New(config["uri.owner"].AsUri);

            // check for service access keys
            var internalAccessKey = config["internal-service-key"].AsText;

            if (!string.IsNullOrEmpty(internalAccessKey))
            {
                _internalAccessKey = internalAccessKey;
            }
            var privateAccessKey = config["private-service-key"].AsText;

            if (!string.IsNullOrEmpty(privateAccessKey))
            {
                _privateAccessKey = privateAccessKey;
            }

            // check for api-key settings
            _apikey = config["apikey"].AsText;

            // process 'set-cookie' entries
            var setCookies = DreamCookie.ParseAllSetCookieNodes(config["set-cookie"]);

            if (setCookies.Count > 0)
            {
                Cookies.Update(setCookies, null);
            }

            // grant private access key to self, host, and owner
            var privateAcccessCookie = DreamCookie.NewSetCookie("service-key", PrivateAccessKey, Self.Uri);

            Cookies.Update(privateAcccessCookie, null);
            yield return(Env.At("@grants").Post(DreamMessage.Ok(privateAcccessCookie.AsSetCookieDocument), new Result <DreamMessage>(TimeSpan.MaxValue)));

            if (Owner != null)
            {
                yield return(res = Owner.At("@grants").Post(DreamMessage.Ok(privateAcccessCookie.AsSetCookieDocument), new Result <DreamMessage>(TimeSpan.MaxValue)));

                if (!res.Value.IsSuccessful)
                {
                    throw new ArgumentException("unexpected failure setting grants on owner service");
                }
            }

            // check if this service requires a service-license to work
            if (this is IDreamServiceLicense)
            {
                string service_license = config["service-license"].AsText;
                if (string.IsNullOrEmpty(service_license))
                {
                    throw new DreamAbortException(DreamMessage.LicenseRequired("service-license missing"));
                }

                // extract public RSA key for validation
                RSACryptoServiceProvider public_key = RSAUtil.ProviderFrom(GetType().Assembly);
                if (public_key == null)
                {
                    throw new DreamAbortException(DreamMessage.InternalError("service assembly invalid"));
                }

                // validate the service-license
                _license = null;
                Dictionary <string, string> values;
                try {
                    // parse service-license
                    values = HttpUtil.ParseNameValuePairs(service_license);
                    if (!Encoding.UTF8.GetBytes(service_license.Substring(0, service_license.LastIndexOf(','))).VerifySignature(values["dsig"], public_key))
                    {
                        throw new DreamAbortException(DreamMessage.InternalError("invalid service-license (1)"));
                    }

                    // check if the SID matches
                    string sid;
                    if (!values.TryGetValue("sid", out sid) || !SID.HasPrefix(XUri.TryParse(sid), true))
                    {
                        throw new DreamAbortException(DreamMessage.InternalError("invalid service-license (2)"));
                    }
                    _license = service_license;
                } catch (Exception e) {
                    // unexpected error, blame it on the license
                    if (e is DreamAbortException)
                    {
                        throw;
                    }
                    throw new DreamAbortException(DreamMessage.InternalError("corrupt service-license (1)"));
                }

                // validate expiration date
                string expirationtext;
                if (values.TryGetValue("expire", out expirationtext))
                {
                    try {
                        DateTime expiration = DateTime.Parse(expirationtext);
                        if (expiration < GlobalClock.UtcNow)
                        {
                            _license = null;
                        }
                    } catch (Exception e) {
                        _license = null;

                        // unexpected error, blame it on the license
                        if (e is DreamAbortException)
                        {
                            throw;
                        }
                        throw new DreamAbortException(DreamMessage.InternalError("corrupt service-license (2)"));
                    }
                }

                // check if a license was assigned
                if (_license == null)
                {
                    throw new DreamAbortException(DreamMessage.LicenseRequired("service-license has expired"));
                }
            }
            else
            {
                config["service-license"].RemoveAll();
            }

            // create built-in services
            _storage = Plug.New(config["uri.storage"].AsUri);

            // done
            _log.Debug("Start");
            result.Return();
        }
Beispiel #7
0
 public void OnSIDDisconnect(SID sid)
 {
 }
Beispiel #8
0
        /// <summary>
        /// The load ent controls.
        /// </summary>
        /// <param name="entArray">The ent array.</param>
        /// <remarks></remarks>
        private void LoadENTControls(object[] entArray)
        {
            this.selectedTagType = map.SelectedMeta.type;

            this.toolStripTagType.Text = "[" + this.selectedTagType + "]";
            this.toolStripTagName.Text = map.SelectedMeta.name;

            // this.Padding = new Padding(10);
            int colorSpaceCount = 4;

            // Custom Plugins access
            //ra = new RegistryAccess(
            //    Registry.CurrentUser,
            //    RegistryAccess.RegPaths.Halo2CustomPlugins + pluginName + "\\" + this.selectedTagType);
            //if (pluginName == null)
            //{
            //    ra.CloseReg();
            //}

            if (entArray != null)
                foreach (object o in entArray)
                {
                    IFPIO.BaseObject tempbase = (IFPIO.BaseObject)o;
                    if (tempbase.visible == false)
                    {
                        if (ShowInvisibles == false)
                        {
                            continue;
                        }
                    }

                    // skip hidden custom plugins variables (mark reflexives to be removed if empty)
                    bool skipEmptyReflex = false;
                    //if (ra.isOpen && ra.getValue(tempbase.offset.ToString()) == bool.FalseString)
                    //{
                    //    if (tempbase.ObjectType == IFPIO.ObjectEnum.Struct)
                    //    {
                    //        skipEmptyReflex = true;
                    //    }
                    //    else
                    //    {
                    //        continue;
                    //    }
                    //}

                    switch (tempbase.ObjectType)
                    {
                        case IFPIO.ObjectEnum.Struct:
                            {
                                if (ShowReflexives == false)
                                {
                                    break;
                                }

                                // tempLabel is a blank space located above reflexives
                                Label tempLabel = new Label();
                                tempLabel.AutoSize = true;
                                tempLabel.Location = new Point(0, 0);
                                tempLabel.Name = "label1";
                                tempLabel.Dock = DockStyle.Top;
                                tempLabel.Size = new Size(35, 13);
                                tempLabel.TabIndex = tabIndex;

                                // tempReflexive is the reflexive and all data (incl other reflexives) within it
                                ReflexiveControl tempReflexive = new ReflexiveControl(
                                    map,
                                    map.SelectedMeta.offset,
                                    ((IFPIO.Reflexive)tempbase).HasCount,
                                    tempbase.lineNumber,
                                    this);

                                // tempReflexive.Location = new System.Drawing.Point(10, 0);
                                tempReflexive.Name = "reflexive";
                                tempReflexive.TabIndex = tabIndex;
                                tempReflexive.LoadENTControls(
                                    (IFPIO.Reflexive)tempbase,
                                    ((IFPIO.Reflexive)tempbase).items,
                                    true,
                                    0,
                                    ref tabIndex,
                                    tempbase.offset.ToString());

                                // Label, Combobox & Button are always added ( = 3)
                                if (!(tempReflexive.Controls.Count <= 2 && skipEmptyReflex))
                                {
                                    this.Controls[0].Controls.Add(tempLabel);
                                    tempLabel.BringToFront();
                                    this.Controls[0].Controls.Add(tempReflexive);
                                    tempReflexive.BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Ident:
                            {
                                if (ShowIdents == false)
                                {
                                    break;
                                }

                                Ident tempident = new Ident(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Ident)tempbase).hasTagType,
                                    tempbase.lineNumber);
                                tempident.Name = "ident";
                                tempident.TabIndex = tabIndex;
                                tempident.Populate(map.SelectedMeta.offset);
                                tempident.Tag = "[" + tempident.Controls[2].Text + "] " + tempident.Controls[1].Text;
                                tempident.Controls[1].ContextMenuStrip = identContext;
                                this.Controls[0].Controls.Add(tempident);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.StringID:
                            {
                                if (ShowSIDs == false)
                                {
                                    break;
                                }

                                SID tempSID = new SID(tempbase.name, map, tempbase.offset, tempbase.lineNumber);
                                tempSID.Name = "sid";
                                tempSID.TabIndex = tabIndex;
                                tempSID.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempSID);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Float:
                            {
                                if (ShowFloats == false)
                                {
                                    break;
                                }

                                DataValues tempFloat = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Float, tempbase.lineNumber);
                                tempFloat.TabIndex = tabIndex;
                                tempFloat.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempFloat);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.String32:
                            {
                                if (ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                                {
                                    break;
                                }

                                EntStrings tempstring = new EntStrings(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPString)tempbase).size,
                                    ((IFPIO.IFPString)tempbase).type,
                                    tempbase.lineNumber);
                                tempstring.Name = "string";
                                tempstring.TabIndex = tabIndex;
                                tempstring.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempstring);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.UnicodeString256:
                            {
                                if (ShowUnicodeString256s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.String256:
                            {
                                if (ShowString256s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.UnicodeString64:
                            {
                                if (ShowUnicodeString64s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.String:
                            {
                                if (ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                                {
                                    break;
                                }

                                EntStrings tempstring = new EntStrings(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPString)tempbase).size,
                                    ((IFPIO.IFPString)tempbase).type,
                                    tempbase.lineNumber);
                                tempstring.Name = "string";
                                tempstring.TabIndex = tabIndex;
                                tempstring.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempstring);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Int:
                            {
                                if (((IFPIO.IFPInt)tempbase).entIndex.nulled)
                                {
                                    if ((ShowInts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Int) ||
                                        (ShowShorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Short) ||
                                        (ShowUshorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.UShort) ||
                                        (ShowUints == false && tempbase.ObjectType == IFPIO.ObjectEnum.UInt))
                                    {
                                        break;
                                    }

                                    DataValues tempdatavalues = new DataValues(
                                        tempbase.name, map, tempbase.offset, tempbase.ObjectType, tempbase.lineNumber);
                                    tempdatavalues.TabIndex = tabIndex;
                                    tempdatavalues.Populate(map.SelectedMeta.offset);
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }
                                else
                                {
                                    if ((ShowBlockIndex32s == false &&
                                         (tempbase.ObjectType == IFPIO.ObjectEnum.Int |
                                          tempbase.ObjectType == IFPIO.ObjectEnum.UInt)) ||
                                        (ShowBlockIndex16s == false &&
                                         (tempbase.ObjectType == IFPIO.ObjectEnum.Short |
                                          tempbase.ObjectType == IFPIO.ObjectEnum.UShort)) ||
                                        (ShowBlockIndex8s == false && tempbase.ObjectType == IFPIO.ObjectEnum.Byte))
                                    {
                                        break;
                                    }

                                    Indices tempdatavalues = new Indices(
                                        tempbase.name,
                                        map,
                                        tempbase.offset,
                                        tempbase.ObjectType,
                                        ((IFPIO.IFPInt)tempbase).entIndex);
                                    tempdatavalues.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Short:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.UShort:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.UInt:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.Unknown:
                            {
                                if (ShowUndefineds == false)
                                {
                                    break;
                                }

                                DataValues tempUnknown = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Unknown, tempbase.lineNumber);
                                tempUnknown.TabIndex = tabIndex;
                                tempUnknown.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempUnknown);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Byte_Flags:
                            {
                                if (ShowBitmask8s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Word_Flags:
                            {
                                if (ShowBitmask16s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Long_Flags:
                            {
                                if (ShowBitmask32s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Char_Enum:
                            {
                                if (ShowEnum8s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Enum:
                            {
                                if (ShowEnum16s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Long_Enum:
                            {
                                if (ShowEnum32s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Byte:
                            {
                                if (((IFPIO.IFPByte)tempbase).entIndex.nulled)
                                {
                                    if (ShowBytes == false)
                                    {
                                        break;
                                    }

                                    DataValues tempByte = new DataValues(
                                        tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Byte, tempbase.lineNumber);
                                    tempByte.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempByte);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }
                                else
                                {
                                    if (ShowBlockIndex8s == false)
                                    {
                                        break;
                                    }

                                    Indices tempdatavalues = new Indices(
                                        tempbase.name,
                                        map,
                                        tempbase.offset,
                                        tempbase.ObjectType,
                                        ((IFPIO.IFPByte)tempbase).entIndex);
                                    tempdatavalues.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Unused:
                            {
                                DataValues tempUnknown = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Unused, tempbase.lineNumber);
                                tempUnknown.TabIndex = tabIndex;
                                tempUnknown.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempUnknown);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.TagType:
                            continue;
                    }

                    if (!(tempbase is IFPIO.Reflexive))
                    {
                        ToolTip1.SetToolTip(this.Controls[0].Controls[0].Controls[0], "offset: " + tempbase.offset);
                    }

                    if (this.Controls[0].Controls.Count > 0 && this.Controls[0].Controls[0] is DataValues)
                    {
                        // if (((tempbase.name.ToLower().Contains(" a") & tempbase.name[tempbase.name.ToLower().IndexOf(" a")]) ||
                        // tempbase.name.ToLower().Contains("alpha"))& alphaControl == null)
                        if (ColorWheel.checkForColor(tempbase.name, alphaControl, " a", "alpha"))
                        {
                            alphaControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" r") & redControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, redControl, " r", "red"))
                        {
                            redControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" g") & greenControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, greenControl, " g", "green"))
                        {
                            greenControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" b") & blueControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, blueControl, " b", "blue"))
                        {
                            blueControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }
                        else
                        {
                            colorSpaceCount++;
                            if (colorSpaceCount == 1)
                            {
                                alphaControl = null;
                                redControl = null;
                                greenControl = null;
                                blueControl = null;
                            }
                        }

                        if (redControl != null & greenControl != null & blueControl != null)
                        {
                            // Create the new ColorWheel class, indicating
                            // the locations of the color wheel itself, the
                            // brightness area, and the position of the selected color.
                            ColorWheel cw = new ColorWheel();

                            if (alphaControl != null)
                            {
                                cw.setTextBox(alphaControl.textBox1, Color.White);
                            }

                            cw.setTextBox(redControl.textBox1, Color.Red);
                            cw.setTextBox(greenControl.textBox1, Color.Green);
                            cw.setTextBox(blueControl.textBox1, Color.Blue);

                            // p.I.AddRange(new Rectangle[] { SelectedColorRectangle });
                            cw.Dock = DockStyle.Top;
                            this.Controls[0].Controls.Add(cw);
                            this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();

                            // Reset for next batch
                            colorSpaceCount++;
                            alphaControl = null;
                            redControl = null;
                            greenControl = null;
                            blueControl = null;
                        }
                    }
                    else
                    {
                        colorSpaceCount++;
                    }

                    tabIndex++;
                }

            //ra.CloseReg();
        }
Beispiel #9
0
        private static List <Dictionary <string, string> > GetPuttySessions()
        {
            List <Dictionary <string, string> > results = new List <Dictionary <string, string> >();

            // extracts saved putty sessions and basic configs (via the registry)
            if (MyUtils.IsHighIntegrity())
            {
                Console.WriteLine("\r\n\r\n=== Putty Saved Session Information (All Users) ===\r\n");

                string[] SIDs = Registry.Users.GetSubKeyNames();
                foreach (string SID in SIDs)
                {
                    if (SID.StartsWith("S-1-5") && !SID.EndsWith("_Classes"))
                    {
                        string[] subKeys = RegistryHelper.GetRegSubkeys("HKU", string.Format("{0}\\Software\\SimonTatham\\PuTTY\\Sessions\\", SID));

                        foreach (string sessionName in subKeys)
                        {
                            Dictionary <string, string> putty_sess = new Dictionary <string, string>()
                            {
                                { "User SID", SID },
                                { "SessionName", sessionName },
                                { "HostName", "" },
                                { "PortNumber", "" },
                                { "UserName", "" },
                                { "PublicKeyFile", "" },
                                { "PortForwardings", "" },
                                { "ConnectionSharing", "" },
                                { "ProxyPassword", "" },
                                { "ProxyUsername", "" },
                            };

                            string[] keys =
                            {
                                "HostName",
                                "PortNumber",
                                "UserName",
                                "PublicKeyFile",
                                "PortForwardings",
                                "ConnectionSharing",
                                "AgentFwd",
                                "ProxyPassword",
                                "ProxyUsername",
                            };

                            foreach (string key in keys)
                            {
                                putty_sess[key] = RegistryHelper.GetRegValue("HKU", string.Format("{0}\\Software\\SimonTatham\\PuTTY\\Sessions\\{1}", SID, sessionName), key);
                            }

                            results.Add(putty_sess);
                        }
                    }
                }
            }
            else
            {
                string[] subKeys = RegistryHelper.GetRegSubkeys("HKCU", "Software\\SimonTatham\\PuTTY\\Sessions\\");
                foreach (string sessionName in subKeys)
                {
                    Dictionary <string, string> putty_sess = new Dictionary <string, string>()
                    {
                        { "SessionName", sessionName },
                        { "HostName", "" },
                        { "PortNumber", "" },
                        { "UserName", "" },
                        { "PublicKeyFile", "" },
                        { "PortForwardings", "" },
                        { "ConnectionSharing", "" },
                        { "ProxyPassword", "" },
                        { "ProxyUsername", "" },
                    };

                    string[] keys =
                    {
                        "HostName",
                        "PortNumber",
                        "UserName",
                        "PublicKeyFile",
                        "PortForwardings",
                        "ConnectionSharing",
                        "AgentFwd",
                        "ProxyPassword",
                        "ProxyUsername",
                    };

                    foreach (string key in keys)
                    {
                        putty_sess[key] = RegistryHelper.GetRegValue("HKCU", string.Format("Software\\SimonTatham\\PuTTY\\Sessions\\{0}", sessionName), key);
                    }

                    results.Add(putty_sess);
                }
            }
            return(results);
        }
Beispiel #10
0
 public SidAndAttributes(SID sid, SidAttributes attributes)
 {
     Sid        = sid;
     Attributes = attributes;
 }
Beispiel #11
0
        public unsafe void KnownSidNotEqualsDefault()
        {
            SID sid = Security.CreateWellKnownSid(WellKnownSID.IISUser);

            sid.Equals(default).Should().BeFalse();
Beispiel #12
0
        public void KnownSidEqualsSelf()
        {
            SID sid = Security.CreateWellKnownSid(WellKnownSID.IISUser);

            sid.Equals(sid).Should().BeTrue();
        }
Beispiel #13
0
        public void EmptySidEqualsDefault()
        {
            SID sid = new SID();

            sid.Equals(new SID()).Should().BeTrue();
        }
Beispiel #14
0
        public void EmptySidEqualsSelf()
        {
            SID sid = new SID();

            sid.Equals(sid).Should().BeTrue();
        }
Beispiel #15
0
 public void OnConnect(SID sid)
 {
     sid.OnComplete   += OnSIDComplete;
     sid.OnDisconnect += OnSIDDisconnect;
 }
        /// <summary>
        /// ProcessRecord method.
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                LocalUser user = null;

                if (InputObject != null)
                {
                    if (CheckShouldProcess(InputObject.ToString()))
                    {
                        user = InputObject;
                    }
                }
                else if (Name != null)
                {
                    user = sam.GetLocalUser(Name);

                    if (!CheckShouldProcess(Name))
                    {
                        user = null;
                    }
                }
                else if (SID != null)
                {
                    user = sam.GetLocalUser(SID);

                    if (!CheckShouldProcess(SID.ToString()))
                    {
                        user = null;
                    }
                }

                if (user == null)
                {
                    return;
                }

                // We start with what already exists
                var  delta = user.Clone();
                bool?passwordNeverExpires = null;

                foreach (var paramName in parameterNames)
                {
                    if (this.HasParameter(paramName))
                    {
                        switch (paramName)
                        {
                        case "AccountExpires":
                            delta.AccountExpires = this.AccountExpires;
                            break;

                        case "Description":
                            delta.Description = this.Description;
                            break;

                        case "FullName":
                            delta.FullName = this.FullName;
                            break;

                        case "UserMayChangePassword":
                            delta.UserMayChangePassword = this.UserMayChangePassword;
                            break;

                        case "PasswordNeverExpires":
                            passwordNeverExpires = this.PasswordNeverExpires;
                            break;
                        }
                    }
                }

                if (AccountNeverExpires.IsPresent)
                {
                    delta.AccountExpires = null;
                }

                sam.UpdateLocalUser(user, delta, Password, passwordNeverExpires);
            }
            catch (Exception ex)
            {
                WriteError(ex.MakeErrorRecord());
            }
        }
Beispiel #17
0
 /// <summary>
 /// Provides a string representation of the Principal.
 /// </summary>
 /// <returns>
 /// A string, in SDDL form, representing the Principal.
 /// </returns>
 public override string ToString()
 {
     return(Name ?? SID.ToString());
 }
Beispiel #18
0
        /// <summary>
        /// Constructs an HL7 segment for the specified Segments enum object
        /// </summary>
        /// <param name="seg">The Segments enum object to construct for</param>
        public Segment(Segments seg)
        {
            switch (seg)
            {
            case Segments.ABS:
                ABS abs = new ABS();
                Name        = abs.Name;
                Description = abs.Description;
                Fields      = abs.Fields;
                break;

            case Segments.ACC:
                ACC acc = new ACC();
                Name        = acc.Name;
                Description = acc.Description;
                Fields      = acc.Fields;
                break;

            case Segments.ADD:
                ADD add = new ADD();
                Name        = add.Name;
                Description = add.Description;
                Fields      = add.Fields;
                break;

            case Segments.AFF:
                AFF aff = new AFF();
                Name        = aff.Name;
                Description = aff.Description;
                Fields      = aff.Fields;
                break;

            case Segments.AIG:
                AIG aig = new AIG();
                Name        = aig.Name;
                Description = aig.Description;
                Fields      = aig.Fields;
                break;

            case Segments.AIL:
                AIL ail = new AIL();
                Name        = ail.Name;
                Description = ail.Description;
                Fields      = ail.Fields;
                break;

            case Segments.AIP:
                AIP aip = new AIP();
                Name        = aip.Name;
                Description = aip.Description;
                Fields      = aip.Fields;
                break;

            case Segments.AIS:
                AIS ais = new AIS();
                Name        = ais.Name;
                Description = ais.Description;
                Fields      = ais.Fields;
                break;

            case Segments.AL1:
                AL1 al1 = new AL1();
                Name        = al1.Name;
                Description = al1.Description;
                Fields      = al1.Fields;
                break;

            case Segments.APR:
                APR apr = new APR();
                Name        = apr.Name;
                Description = apr.Description;
                Fields      = apr.Fields;
                break;

            case Segments.ARQ:
                ARQ arq = new ARQ();
                Name        = arq.Name;
                Description = arq.Description;
                Fields      = arq.Fields;
                break;

            case Segments.AUT:
                AUT aut = new AUT();
                Name        = aut.Name;
                Description = aut.Description;
                Fields      = aut.Fields;
                break;

            case Segments.BHS:
                BHS bhs = new BHS();
                Name        = bhs.Name;
                Description = bhs.Description;
                Fields      = bhs.Fields;
                break;

            case Segments.BLC:
                BLC blc = new BLC();
                Name        = blc.Name;
                Description = blc.Description;
                Fields      = blc.Fields;
                break;

            case Segments.BLG:
                BLG blg = new BLG();
                Name        = blg.Name;
                Description = blg.Description;
                Fields      = blg.Fields;
                break;

            case Segments.BPO:
                BPO bpo = new BPO();
                Name        = bpo.Name;
                Description = bpo.Description;
                Fields      = bpo.Fields;
                break;

            case Segments.BPX:
                BPX bpx = new BPX();
                Name        = bpx.Name;
                Description = bpx.Description;
                Fields      = bpx.Fields;
                break;

            case Segments.BTS:
                BTS bts = new BTS();
                Name        = bts.Name;
                Description = bts.Description;
                Fields      = bts.Fields;
                break;

            case Segments.BTX:
                BTX btx = new BTX();
                Name        = btx.Name;
                Description = btx.Description;
                Fields      = btx.Fields;
                break;

            case Segments.CDM:
                CDM cdm = new CDM();
                Name        = cdm.Name;
                Description = cdm.Description;
                Fields      = cdm.Fields;
                break;

            case Segments.CER:
                CER cer = new CER();
                Name        = cer.Name;
                Description = cer.Description;
                Fields      = cer.Fields;
                break;

            case Segments.CM0:
                CM0 cm0 = new CM0();
                Name        = cm0.Name;
                Description = cm0.Description;
                Fields      = cm0.Fields;
                break;

            case Segments.CM1:
                CM1 cm1 = new CM1();
                Name        = cm1.Name;
                Description = cm1.Description;
                Fields      = cm1.Fields;
                break;

            case Segments.CM2:
                CM2 cm2 = new CM2();
                Name        = cm2.Name;
                Description = cm2.Description;
                Fields      = cm2.Fields;
                break;

            case Segments.CNS:
                CNS cns = new CNS();
                Name        = cns.Name;
                Description = cns.Description;
                Fields      = cns.Fields;
                break;

            case Segments.CON:
                CON con = new CON();
                Name        = con.Name;
                Description = con.Description;
                Fields      = con.Fields;
                break;

            case Segments.CSP:
                CSP csp = new CSP();
                Name        = csp.Name;
                Description = csp.Description;
                Fields      = csp.Fields;
                break;

            case Segments.CSR:
                CSR csr = new CSR();
                Name        = csr.Name;
                Description = csr.Description;
                Fields      = csr.Fields;
                break;

            case Segments.CSS:
                CSS css = new CSS();
                Name        = css.Name;
                Description = css.Description;
                Fields      = css.Fields;
                break;

            case Segments.CTD:
                CTD ctd = new CTD();
                Name        = ctd.Name;
                Description = ctd.Description;
                Fields      = ctd.Fields;
                break;

            case Segments.CTI:
                CTI cti = new CTI();
                Name        = cti.Name;
                Description = cti.Description;
                Fields      = cti.Fields;
                break;

            case Segments.DB1:
                DB1 db1 = new DB1();
                Name        = db1.Name;
                Description = db1.Description;
                Fields      = db1.Fields;
                break;

            case Segments.DG1:
                DG1 dg1 = new DG1();
                Name        = dg1.Name;
                Description = dg1.Description;
                Fields      = dg1.Fields;
                break;

            case Segments.DRG:
                DRG drg = new DRG();
                Name        = drg.Name;
                Description = drg.Description;
                Fields      = drg.Fields;
                break;

            case Segments.DSC:
                DSC dsc = new DSC();
                Name        = dsc.Name;
                Description = dsc.Description;
                Fields      = dsc.Fields;
                break;

            case Segments.DSP:
                DSP dsp = new DSP();
                Name        = dsp.Name;
                Description = dsp.Description;
                Fields      = dsp.Fields;
                break;

            case Segments.ECD:
                ECD ecd = new ECD();
                Name        = ecd.Name;
                Description = ecd.Description;
                Fields      = ecd.Fields;
                break;

            case Segments.ECR:
                ECR ecr = new ECR();
                Name        = ecr.Name;
                Description = ecr.Description;
                Fields      = ecr.Fields;
                break;

            case Segments.EDU:
                EDU edu = new EDU();
                Name        = edu.Name;
                Description = edu.Description;
                Fields      = edu.Fields;
                break;

            case Segments.EQL:
                EQL eql = new EQL();
                Name        = eql.Name;
                Description = eql.Description;
                Fields      = eql.Fields;
                break;

            case Segments.EQP:
                EQP eqp = new EQP();
                Name        = eqp.Name;
                Description = eqp.Description;
                Fields      = eqp.Fields;
                break;

            case Segments.EQU:
                EQU equ = new EQU();
                Name        = equ.Name;
                Description = equ.Description;
                Fields      = equ.Fields;
                break;

            case Segments.ERQ:
                ERQ erq = new ERQ();
                Name        = erq.Name;
                Description = erq.Description;
                Fields      = erq.Fields;
                break;

            case Segments.ERR:
                ERR err = new ERR();
                Name        = err.Name;
                Description = err.Description;
                Fields      = err.Fields;
                break;

            case Segments.EVN:
                EVN evn = new EVN();
                Name        = evn.Name;
                Description = evn.Description;
                Fields      = evn.Fields;
                break;

            case Segments.FAC:
                FAC fac = new FAC();
                Name        = fac.Name;
                Description = fac.Description;
                Fields      = fac.Fields;
                break;

            case Segments.FHS:
                FHS fhs = new FHS();
                Name        = fhs.Name;
                Description = fhs.Description;
                Fields      = fhs.Fields;
                break;

            case Segments.FT1:
                FT1 ft1 = new FT1();
                Name        = ft1.Name;
                Description = ft1.Description;
                Fields      = ft1.Fields;
                break;

            case Segments.FTS:
                FTS fts = new FTS();
                Name        = fts.Name;
                Description = fts.Description;
                Fields      = fts.Fields;
                break;

            case Segments.GOL:
                GOL gol = new GOL();
                Name        = gol.Name;
                Description = gol.Description;
                Fields      = gol.Fields;
                break;

            case Segments.GP1:
                GP1 gp1 = new GP1();
                Name        = gp1.Name;
                Description = gp1.Description;
                Fields      = gp1.Fields;
                break;

            case Segments.GP2:
                GP2 gp2 = new GP2();
                Name        = gp2.Name;
                Description = gp2.Description;
                Fields      = gp2.Fields;
                break;

            case Segments.GT1:
                GT1 gt1 = new GT1();
                Name        = gt1.Name;
                Description = gt1.Description;
                Fields      = gt1.Fields;
                break;

            case Segments.IAM:
                IAM iam = new IAM();
                Name        = iam.Name;
                Description = iam.Description;
                Fields      = iam.Fields;
                break;

            case Segments.IIM:
                IIM iim = new IIM();
                Name        = iim.Name;
                Description = iim.Description;
                Fields      = iim.Fields;
                break;

            case Segments.IN1:
                IN1 in1 = new IN1();
                Name        = in1.Name;
                Description = in1.Description;
                Fields      = in1.Fields;
                break;

            case Segments.IN2:
                IN2 in2 = new IN2();
                Name        = in2.Name;
                Description = in2.Description;
                Fields      = in2.Fields;
                break;

            case Segments.IN3:
                IN3 in3 = new IN3();
                Name        = in3.Name;
                Description = in3.Description;
                Fields      = in3.Fields;
                break;

            case Segments.INV:
                INV inv = new INV();
                Name        = inv.Name;
                Description = inv.Description;
                Fields      = inv.Fields;
                break;

            case Segments.IPC:
                IPC ipc = new IPC();
                Name        = ipc.Name;
                Description = ipc.Description;
                Fields      = ipc.Fields;
                break;

            case Segments.ISD:
                ISD isd = new ISD();
                Name        = isd.Name;
                Description = isd.Description;
                Fields      = isd.Fields;
                break;

            case Segments.LAN:
                LAN lan = new LAN();
                Name        = lan.Name;
                Description = lan.Description;
                Fields      = lan.Fields;
                break;

            case Segments.LCC:
                LCC lcc = new LCC();
                Name        = lcc.Name;
                Description = lcc.Description;
                Fields      = lcc.Fields;
                break;

            case Segments.LCH:
                LCH lch = new LCH();
                Name        = lch.Name;
                Description = lch.Description;
                Fields      = lch.Fields;
                break;

            case Segments.LDP:
                LDP ldp = new LDP();
                Name        = ldp.Name;
                Description = ldp.Description;
                Fields      = ldp.Fields;
                break;

            case Segments.LOC:
                LOC loc = new LOC();
                Name        = loc.Name;
                Description = loc.Description;
                Fields      = loc.Fields;
                break;

            case Segments.LRL:
                LRL lrl = new LRL();
                Name        = lrl.Name;
                Description = lrl.Description;
                Fields      = lrl.Fields;
                break;

            case Segments.MFA:
                MFA mfa = new MFA();
                Name        = mfa.Name;
                Description = mfa.Description;
                Fields      = mfa.Fields;
                break;

            case Segments.MFE:
                MFE mfe = new MFE();
                Name        = mfe.Name;
                Description = mfe.Description;
                Fields      = mfe.Fields;
                break;

            case Segments.MFI:
                MFI mfi = new MFI();
                Name        = mfi.Name;
                Description = mfi.Description;
                Fields      = mfi.Fields;
                break;

            case Segments.MRG:
                MRG mrg = new MRG();
                Name        = mrg.Name;
                Description = mrg.Description;
                Fields      = mrg.Fields;
                break;

            case Segments.MSA:
                MSA msa = new MSA();
                Name        = msa.Name;
                Description = msa.Description;
                Fields      = msa.Fields;
                break;

            case Segments.MSH:
                MSH msh = new MSH();
                Name        = msh.Name;
                Description = msh.Description;
                Fields      = msh.Fields;
                break;

            case Segments.NCK:
                NCK nck = new NCK();
                Name        = nck.Name;
                Description = nck.Description;
                Fields      = nck.Fields;
                break;

            case Segments.NDS:
                NDS nds = new NDS();
                Name        = nds.Name;
                Description = nds.Description;
                Fields      = nds.Fields;
                break;

            case Segments.NK1:
                NK1 nk1 = new NK1();
                Name        = nk1.Name;
                Description = nk1.Description;
                Fields      = nk1.Fields;
                break;

            case Segments.NPU:
                NPU npu = new NPU();
                Name        = npu.Name;
                Description = npu.Description;
                Fields      = npu.Fields;
                break;

            case Segments.NSC:
                NSC nsc = new NSC();
                Name        = nsc.Name;
                Description = nsc.Description;
                Fields      = nsc.Fields;
                break;

            case Segments.NST:
                NST nst = new NST();
                Name        = nst.Name;
                Description = nst.Description;
                Fields      = nst.Fields;
                break;

            case Segments.NTE:
                NTE nte = new NTE();
                Name        = nte.Name;
                Description = nte.Description;
                Fields      = nte.Fields;
                break;

            case Segments.OBR:
                OBR obr = new OBR();
                Name        = obr.Name;
                Description = obr.Description;
                Fields      = obr.Fields;
                break;

            case Segments.OBX:
                OBX obx = new OBX();
                Name        = obx.Name;
                Description = obx.Description;
                Fields      = obx.Fields;
                break;

            case Segments.ODS:
                ODS ods = new ODS();
                Name        = ods.Name;
                Description = ods.Description;
                Fields      = ods.Fields;
                break;

            case Segments.ODT:
                ODT odt = new ODT();
                Name        = odt.Name;
                Description = odt.Description;
                Fields      = odt.Fields;
                break;

            case Segments.OM1:
                OM1 om1 = new OM1();
                Name        = om1.Name;
                Description = om1.Description;
                Fields      = om1.Fields;
                break;

            case Segments.OM2:
                OM2 om2 = new OM2();
                Name        = om2.Name;
                Description = om2.Description;
                Fields      = om2.Fields;
                break;

            case Segments.OM3:
                OM3 om3 = new OM3();
                Name        = om3.Name;
                Description = om3.Description;
                Fields      = om3.Fields;
                break;

            case Segments.OM4:
                OM4 om4 = new OM4();
                Name        = om4.Name;
                Description = om4.Description;
                Fields      = om4.Fields;
                break;

            case Segments.OM5:
                OM5 om5 = new OM5();
                Name        = om5.Name;
                Description = om5.Description;
                Fields      = om5.Fields;
                break;

            case Segments.OM6:
                OM6 om6 = new OM6();
                Name        = om6.Name;
                Description = om6.Description;
                Fields      = om6.Fields;
                break;

            case Segments.OM7:
                OM7 om7 = new OM7();
                Name        = om7.Name;
                Description = om7.Description;
                Fields      = om7.Fields;
                break;

            case Segments.ORC:
                ORC orc = new ORC();
                Name        = orc.Name;
                Description = orc.Description;
                Fields      = orc.Fields;
                break;

            case Segments.ORG:
                ORG org = new ORG();
                Name        = org.Name;
                Description = org.Description;
                Fields      = org.Fields;
                break;

            case Segments.OVR:
                OVR ovr = new OVR();
                Name        = ovr.Name;
                Description = ovr.Description;
                Fields      = ovr.Fields;
                break;

            case Segments.PCR:
                PCR pcr = new PCR();
                Name        = pcr.Name;
                Description = pcr.Description;
                Fields      = pcr.Fields;
                break;

            case Segments.PD1:
                PD1 pd1 = new PD1();
                Name        = pd1.Name;
                Description = pd1.Description;
                Fields      = pd1.Fields;
                break;

            case Segments.PDA:
                PDA pda = new PDA();
                Name        = pda.Name;
                Description = pda.Description;
                Fields      = pda.Fields;
                break;

            case Segments.PDC:
                PDC pdc = new PDC();
                Name        = pdc.Name;
                Description = pdc.Description;
                Fields      = pdc.Fields;
                break;

            case Segments.PEO:
                PEO peo = new PEO();
                Name        = peo.Name;
                Description = peo.Description;
                Fields      = peo.Fields;
                break;

            case Segments.PES:
                PES pes = new PES();
                Name        = pes.Name;
                Description = pes.Description;
                Fields      = pes.Fields;
                break;

            case Segments.PID:
                PID pid = new PID();
                Name        = pid.Name;
                Description = pid.Description;
                Fields      = pid.Fields;
                break;

            case Segments.PR1:
                PR1 pr1 = new PR1();
                Name        = pr1.Name;
                Description = pr1.Description;
                Fields      = pr1.Fields;
                break;

            case Segments.PRA:
                PRA pra = new PRA();
                Name        = pra.Name;
                Description = pra.Description;
                Fields      = pra.Fields;
                break;

            case Segments.PRB:
                PRB prb = new PRB();
                Name        = prb.Name;
                Description = prb.Description;
                Fields      = prb.Fields;
                break;

            case Segments.PRC:
                PRC prc = new PRC();
                Name        = prc.Name;
                Description = prc.Description;
                Fields      = prc.Fields;
                break;

            case Segments.PRD:
                PRD prd = new PRD();
                Name        = prd.Name;
                Description = prd.Description;
                Fields      = prd.Fields;
                break;

            case Segments.PSH:
                PSH psh = new PSH();
                Name        = psh.Name;
                Description = psh.Description;
                Fields      = psh.Fields;
                break;

            case Segments.PTH:
                PTH pth = new PTH();
                Name        = pth.Name;
                Description = pth.Description;
                Fields      = pth.Fields;
                break;

            case Segments.PV1:
                PV1 pv1 = new PV1();
                Name        = pv1.Name;
                Description = pv1.Description;
                Fields      = pv1.Fields;
                break;

            case Segments.PV2:
                PV2 pv2 = new PV2();
                Name        = pv2.Name;
                Description = pv2.Description;
                Fields      = pv2.Fields;
                break;

            case Segments.QAK:
                QAK qak = new QAK();
                Name        = qak.Name;
                Description = qak.Description;
                Fields      = qak.Fields;
                break;

            case Segments.QID:
                QID qid = new QID();
                Name        = qid.Name;
                Description = qid.Description;
                Fields      = qid.Fields;
                break;

            case Segments.QPD:
                QPD qpd = new QPD();
                Name        = qpd.Name;
                Description = qpd.Description;
                Fields      = qpd.Fields;
                break;

            case Segments.QRD:
                QRD qrd = new QRD();
                Name        = qrd.Name;
                Description = qrd.Description;
                Fields      = qrd.Fields;
                break;

            case Segments.QRF:
                QRF qrf = new QRF();
                Name        = qrf.Name;
                Description = qrf.Description;
                Fields      = qrf.Fields;
                break;

            case Segments.QRI:
                QRI qri = new QRI();
                Name        = qri.Name;
                Description = qri.Description;
                Fields      = qri.Fields;
                break;

            case Segments.RCP:
                RCP rcp = new RCP();
                Name        = rcp.Name;
                Description = rcp.Description;
                Fields      = rcp.Fields;
                break;

            case Segments.RDF:
                RDF rdf = new RDF();
                Name        = rdf.Name;
                Description = rdf.Description;
                Fields      = rdf.Fields;
                break;

            case Segments.RF1:
                RF1 rf1 = new RF1();
                Name        = rf1.Name;
                Description = rf1.Description;
                Fields      = rf1.Fields;
                break;

            case Segments.RGS:
                RGS rgs = new RGS();
                Name        = rgs.Name;
                Description = rgs.Description;
                Fields      = rgs.Fields;
                break;

            case Segments.RMI:
                RMI rmi = new RMI();
                Name        = rmi.Name;
                Description = rmi.Description;
                Fields      = rmi.Fields;
                break;

            case Segments.ROL:
                ROL rol = new ROL();
                Name        = rol.Name;
                Description = rol.Description;
                Fields      = rol.Fields;
                break;

            case Segments.RQ1:
                RQ1 rq1 = new RQ1();
                Name        = rq1.Name;
                Description = rq1.Description;
                Fields      = rq1.Fields;
                break;

            case Segments.RQD:
                RQD rqd = new RQD();
                Name        = rqd.Name;
                Description = rqd.Description;
                Fields      = rqd.Fields;
                break;

            case Segments.RXA:
                RXA rxa = new RXA();
                Name        = rxa.Name;
                Description = rxa.Description;
                Fields      = rxa.Fields;
                break;

            case Segments.RXC:
                RXC rxc = new RXC();
                Name        = rxc.Name;
                Description = rxc.Description;
                Fields      = rxc.Fields;
                break;

            case Segments.RXD:
                RXD rxd = new RXD();
                Name        = rxd.Name;
                Description = rxd.Description;
                Fields      = rxd.Fields;
                break;

            case Segments.RXE:
                RXE rxe = new RXE();
                Name        = rxe.Name;
                Description = rxe.Description;
                Fields      = rxe.Fields;
                break;

            case Segments.RXG:
                RXG rxg = new RXG();
                Name        = rxg.Name;
                Description = rxg.Description;
                Fields      = rxg.Fields;
                break;

            case Segments.RXO:
                RXO rxo = new RXO();
                Name        = rxo.Name;
                Description = rxo.Description;
                Fields      = rxo.Fields;
                break;

            case Segments.RXR:
                RXR rxr = new RXR();
                Name        = rxr.Name;
                Description = rxr.Description;
                Fields      = rxr.Fields;
                break;

            case Segments.SAC:
                SAC sac = new SAC();
                Name        = sac.Name;
                Description = sac.Description;
                Fields      = sac.Fields;
                break;

            case Segments.SCH:
                SCH sch = new SCH();
                Name        = sch.Name;
                Description = sch.Description;
                Fields      = sch.Fields;
                break;

            case Segments.SFT:
                SFT sft = new SFT();
                Name        = sft.Name;
                Description = sft.Description;
                Fields      = sft.Fields;
                break;

            case Segments.SID:
                SID sid = new SID();
                Name        = sid.Name;
                Description = sid.Description;
                Fields      = sid.Fields;
                break;

            case Segments.SPM:
                SPM spm = new SPM();
                Name        = spm.Name;
                Description = spm.Description;
                Fields      = spm.Fields;
                break;

            case Segments.SPR:
                SPR spr = new SPR();
                Name        = spr.Name;
                Description = spr.Description;
                Fields      = spr.Fields;
                break;

            case Segments.STF:
                STF stf = new STF();
                Name        = stf.Name;
                Description = stf.Description;
                Fields      = stf.Fields;
                break;

            case Segments.TCC:
                TCC tcc = new TCC();
                Name        = tcc.Name;
                Description = tcc.Description;
                Fields      = tcc.Fields;
                break;

            case Segments.TCD:
                TCD tcd = new TCD();
                Name        = tcd.Name;
                Description = tcd.Description;
                Fields      = tcd.Fields;
                break;

            case Segments.TQ1:
                TQ1 tq1 = new TQ1();
                Name        = tq1.Name;
                Description = tq1.Description;
                Fields      = tq1.Fields;
                break;

            case Segments.TQ2:
                TQ2 tq2 = new TQ2();
                Name        = tq2.Name;
                Description = tq2.Description;
                Fields      = tq2.Fields;
                break;

            case Segments.TXA:
                TXA txa = new TXA();
                Name        = txa.Name;
                Description = txa.Description;
                Fields      = txa.Fields;
                break;

            case Segments.UB1:
                UB1 ub1 = new UB1();
                Name        = ub1.Name;
                Description = ub1.Description;
                Fields      = ub1.Fields;
                break;

            case Segments.UB2:
                UB2 ub2 = new UB2();
                Name        = ub2.Name;
                Description = ub2.Description;
                Fields      = ub2.Fields;
                break;

            case Segments.URD:
                URD urd = new URD();
                Name        = urd.Name;
                Description = urd.Description;
                Fields      = urd.Fields;
                break;

            case Segments.URS:
                URS urs = new URS();
                Name        = urs.Name;
                Description = urs.Description;
                Fields      = urs.Fields;
                break;

            case Segments.VAR:
                VAR var = new VAR();
                Name        = var.Name;
                Description = var.Description;
                Fields      = var.Fields;
                break;

            case Segments.VTQ:
                VTQ vtq = new VTQ();
                Name        = vtq.Name;
                Description = vtq.Description;
                Fields      = vtq.Fields;
                break;
            }
        }
Beispiel #19
0
            /// <summary>
            /// The button 1_ click.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The e.</param>
            /// <remarks></remarks>
            private void button1_Click(object sender, EventArgs e)
            {
                ControlSwapper parent = (ControlSwapper)this.Parent.Parent.Parent;

                // Add selected control
                IFPIO.Option[] options = null;
                //int strLength = 0;
                Control con = null;
                switch (((dataTypeStruct)comboBox1.SelectedItem).name.ToLower())
                {
                    /*
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Byte, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Short, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Int, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Float, parent.lineNum));
                */
                    case "byte":
                    case "short":
                    case "ushort":
                    case "int":
                    case "uint":
                    case "float":
                    case "unknown":
                    case "unused":
                        con = new DataValues(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            (IFPIO.ObjectEnum)
                            Enum.Parse(typeof(IFPIO.ObjectEnum), ((dataTypeStruct)comboBox1.SelectedItem).name, true),
                            parent.lineNum);
                        break;
                    case "char_enum":
                    case "enum":
                    case "long_enum":
                        options = new IFPIO.Option[((dataTypeStruct)comboBox1.SelectedItem).size << 3];

                        // Size * 8 bits
                        for (int x = 0; x < options.Length; x++)
                        {
                            options[x] = new IFPIO.Option("Bit " + x, x.ToString(), parent.lineNum);
                        }

                        if (parent.splitContainer1.Panel1.Controls[0] is Bitmask)
                        {
                            Bitmask b = (Bitmask)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in b.Options)
                            {
                                if (o.value < options.Length)
                                {
                                    options[o.value].name = o.name;
                                }
                            }
                        }

                        ;
                        if (parent.splitContainer1.Panel1.Controls[0] is Enums)
                        {
                            Enums en = (Enums)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in en.Options)
                            {
                                if (o.value < options.Length)
                                {
                                    options[o.value].name = o.name;
                                }
                            }
                        }

                        ;
                        con = new Enums(parent.name, null, parent.chunkoffset, options.Length, options, parent.lineNum);
                        break;
                    case "byte_flags":
                    case "word_flags":
                    case "long_flags":
                        options = new IFPIO.Option[((dataTypeStruct)comboBox1.SelectedItem).size << 3];

                        // Size * 8 bits
                        for (int x = 0; x < options.Length; x++)
                        {
                            options[x] = new IFPIO.Option("Bit " + x, x.ToString(), parent.lineNum);
                        }

                        if (parent.splitContainer1.Panel1.Controls[0] is Bitmask)
                        {
                            Bitmask b = (Bitmask)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in b.Options)
                            {
                                options[o.value].name = o.name;
                            }
                        }

                        ;
                        if (parent.splitContainer1.Panel1.Controls[0] is Enums)
                        {
                            Enums en = (Enums)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in en.Options)
                            {
                                options[o.value].name = o.name;
                            }
                        }

                        ;
                        con = new Bitmask(
                            parent.name, null, parent.chunkoffset, options.Length, options, parent.lineNum);
                        break;
                    case "stringid":
                        con = new SID(parent.name, null, parent.chunkoffset, parent.lineNum);
                        break;
                    case "string":
                        con = new EntStrings(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            ((dataTypeStruct)comboBox1.SelectedItem).size,
                            false,
                            parent.lineNum);
                        break;
                    case "unicodestring":
                        con = new EntStrings(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            ((dataTypeStruct)comboBox1.SelectedItem).size,
                            true,
                            parent.lineNum);
                        break;
                    case "block":
                        con = new TagBlock(parent.name, null, parent.chunkoffset, parent.lineNum);
                        break;
                    case "ident":
                        con = new Ident(parent.name, null, parent.chunkoffset, true, parent.lineNum);
                        break;
                    case "struct":

                        // Unhandled
                        //int ifkdn = 0;
                        break;
                    default:
                        {
                            return;
                        }
                }

                Button but = new Button();
                but.Dock = DockStyle.Right;
                but.Size = new Size(30, 30);
                but.Text = "-";
                but.Click += but_Click;

                if (con != null)
                {
                    con.Controls.Add(but);

                    // con.Enabled = false;
                    con.Dock = DockStyle.Top;
                    Point loc = con.Controls[con.Controls.Count - 2].Location;
                    loc.X -= 50;
                    con.Controls[con.Controls.Count - 2].Location = loc;

                    // con.TabIndex--;
                    parent.splitContainer1.Panel2.Controls.Add(con);
                    con.BringToFront();
                    ((ControlSwapper)this.TopLevelControl).newControlSize +=
                        ((ControlSwapper)this.TopLevelControl).getSizeOf(((dataTypeStruct)comboBox1.SelectedItem).name);
                    if (((ControlSwapper)this.TopLevelControl).label1.Text.Contains(" :: "))
                    {
                        ((ControlSwapper)this.TopLevelControl).label1.Text =
                            ((ControlSwapper)this.TopLevelControl).label1.Text.Remove(
                                ((ControlSwapper)this.TopLevelControl).label1.Text.IndexOf(" :: "));
                    }

                    ((ControlSwapper)this.TopLevelControl).label1.Text += " :: New Control Size : " +
                                                                          ((ControlSwapper)this.TopLevelControl).
                                                                              newControlSize;
                }

                parent.splitContainer1.Panel2.Controls[parent.splitContainer1.Panel2.Controls.IndexOf(this)].
                    BringToFront();
                parent.splitContainer1.Panel2.Controls[parent.splitContainer1.Panel2.Controls.IndexOf(this)].TabIndex++;
            }
Beispiel #20
0
 public NDRSID()
 {
     sid = new SID();
 }
Beispiel #21
0
 public NDRSID(SID sid)
 {
     this.sid = sid;
 }
Beispiel #22
0
 ///<summary>
 ///Removes the given SID
 ///</summary>
 public void RemoveSID(SID toRemove)
 {
     this.RemoveStructure("SID", toRemove);
 }