コード例 #1
0
ファイル: ObjectTypesParser.cs プロジェクト: ypawlak/SnmpLabs
        private static ObjectTypeInfo ParseObjectTypeFromSpecification(string specification)
        {
            IList <ObjectTypeInfo> objTypeInfos = new List <ObjectTypeInfo>();

            foreach (Match match in GetObjectTypeSpecificsRegex().Matches(specification))
            {
                var objTypeI = new ObjectTypeInfo();
                objTypeI.Syntax = match.Groups[OtSyntaxGrp].Value;
                string sizeRestriction    = match.Groups[OtSizeGrp].Value;
                string sizeRestrictionMin = match.Groups[OtSizeMinGrp].Value;
                string sizeRestrictionMax = match.Groups[OtSizeMaxGrp].Value;

                if (string.IsNullOrEmpty(sizeRestriction))
                {
                    if (!string.IsNullOrEmpty(sizeRestrictionMin) &&
                        !string.IsNullOrEmpty(sizeRestrictionMax))
                    {
                        objTypeI.SyntaxSizeRange = new Range <long>(
                            long.Parse(sizeRestrictionMin), long.Parse(sizeRestrictionMax));
                    }
                }
                else
                {
                    objTypeI.SyntaxSize = long.Parse(sizeRestriction);
                }

                //TODO: parse the rest of object types specification

                objTypeInfos.Add(objTypeI);
            }
            return(objTypeInfos.Single());
        }
コード例 #2
0
        private void callback_Callback(object source, CallbackEventArgs e)
        {
            String[]    p      = e.Parameter.Split('|');
            Object      key    = TypeDescriptor.GetConverter(ObjectTypeInfo.KeyMember.MemberType).ConvertFromString(p[0]);
            IMemberInfo member = ObjectTypeInfo.FindMember(p[1]);
            Object      value  = null;

            if (typeof(IXPSimpleObject).IsAssignableFrom(member.MemberType))
            {
                Type memberKeyType = XafTypesInfo.Instance.FindTypeInfo(member.MemberType).KeyMember.MemberType;
                int  index1        = p[2].LastIndexOf("(", StringComparison.Ordinal);
                int  index2        = p[2].LastIndexOf(")", StringComparison.Ordinal);
                if (index1 > 0 && index2 > index1)
                {
                    string memberKeyText = p[2].Substring(index1 + 1, index2 - index1 - 1);
                    value = ObjectSpace.GetObjectByKey(member.MemberType,
                                                       Convert.ChangeType(memberKeyText, memberKeyType));
                }
            }
            else
            {
                value = TypeDescriptor.GetConverter(member.MemberType).ConvertFromString(p[2]);
            }
            object obj = ObjectSpace.GetObjectByKey(ObjectTypeInfo.Type, key);

            member.SetValue(obj, value);
            ObjectSpace.CommitChanges();
        }
コード例 #3
0
    /// <summary>
    /// Determines whether the children objects have their own children
    /// </summary>
    /// <param name="excludedTypes">Excluded child types</param>
    public bool ShowChildrenLevel(List <string> excludedTypes)
    {
        ObjectTypeInfo typeInfo = InfoToClone.TypeInfo;

        if (typeInfo.ChildObjectTypes == null)
        {
            return(false);
        }

        string[] objTypes = typeInfo.ChildObjectTypes.ToArray();
        for (int i = 0; i < objTypes.Length; i++)
        {
            bool allowed = (excludedTypes == null) || !excludedTypes.Contains(objTypes[i]);
            if (allowed)
            {
                ObjectTypeInfo typeInfoChild = ModuleManager.GetReadOnlyObject(objTypes[i]).TypeInfo;
                if ((typeInfoChild.ChildObjectTypes != null) && (typeInfoChild.ChildObjectTypes.Count > 0))
                {
                    return(true);
                }
            }
        }

        return(false);
    }
コード例 #4
0
    private string GetTargetObjectType(ObjectTypeInfo bindingTypeInfo)
    {
        // Search for parent in TYPEINFO
        var parent = bindingTypeInfo.ParentObjectType;

        if (!String.IsNullOrEmpty(parent) && (parent != ObjectType))
        {
            // If parent is different from control's object type use it.
            return(parent);
        }

        // Otherwise search in site object
        var siteObject = bindingTypeInfo.SiteIDColumn;

        if (!String.IsNullOrEmpty(siteObject) && (siteObject != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
        {
            return(SiteInfo.OBJECT_TYPE);
        }

        // If site object not specified use bindings. Find first binding dependency and use it's object type
        var dependency = bindingTypeInfo.ObjectDependencies.FirstOrDefault(x => x.DependencyType == ObjectDependencyEnum.Binding);

        if (dependency != null)
        {
            return(dependency.DependencyObjectType);
        }

        return(null);
    }
コード例 #5
0
    private void InitControls(string objectType, ObjectTypeInfo typeInfo)
    {
        plcMain.Visible = true;

        lblObjectTypeNameValue.Text = TypeHelper.GetNiceObjectTypeName(objectType);
        lblObjectTypeValue.Text     = objectType;

        var dataClass = DataClassInfoProvider.GetDataClassInfo(typeInfo.ObjectClassName);

        lblDBTableValue.Text          = dataClass != null ? dataClass.ClassTableName : GetString("general.none");
        lblSiteRelationshipValue.Text = GetSiteRelationshipTypeDescription(typeInfo.IsSiteObject, typeInfo.SupportsGlobalObjects);
        lblIsBindingValue.Text        = typeInfo.IsBinding ? GetString("general.yes") : GetString("general.no");
        lblSupportsCIValue.Text       = typeInfo.ContinuousIntegrationSettings.Enabled ? GetString("general.yes") : GetString("general.no");

        if (!typeInfo.IsBinding)
        {
            headingObjectTypeGraph.ResourceString = "administration.system.objecttypes.hierarchy";

            lblGraphFilter.Visible = true;
            chlGraphFilter.Visible = true;

            AddGraphFilterOption("administration.system.objecttypegraph.parentobjects", "1");
            AddGraphFilterOption("administration.system.objecttypegraph.childobjects", "2");
            AddGraphFilterOption("administration.system.objecttypegraph.bindings", "4");
            AddGraphFilterOption("administration.system.objecttypegraph.otherbindings", "8");
        }
        else
        {
            headingObjectTypeGraph.ResourceString = "administration.system.objecttypes.bindingrelationships";
        }
    }
コード例 #6
0
        static Type GetTypeAccessRights(ObjectTypeInfo type)
        {
            switch (type.Name.ToLower())
            {
            case "directory":
                return(typeof(DirectoryAccessRights));

            case "event":
                return(typeof(EventAccessRights));

            case "section":
                return(typeof(SectionAccessRights));

            case "mutant":
                return(typeof(MutantAccessRights));

            case "semaphore":
                return(typeof(SemaphoreAccessRights));

            case "job":
                return(typeof(JobObjectAccessRights));

            case "symboliclink":
                return(typeof(SymbolicLinkAccessRights));

            default:
                throw new ArgumentException("Can't get type for access rights");
            }
        }
コード例 #7
0
        static void Main(string[] args)
        {
            bool show_help       = false;
            uint standard_filter = 0;

            int pid = Process.GetCurrentProcess().Id;

            try
            {
                OptionSet opts = new OptionSet()
                {
                    { "r", "Recursive tree directory listing",
                      v => _recursive = v != null },
                    { "sddl", "Print full SDDL security descriptors", v => _print_sddl = v != null },
                    { "p|pid=", "Specify a PID of a process to impersonate when checking", v => pid = int.Parse(v.Trim()) },
                    { "w", "Show only write permissions granted", v => _show_write_only = v != null },
                    { "f=", String.Format("Filter on a specific file right [{0}]",
                                          String.Join(",", Enum.GetNames(typeof(FileAccessRights)))), v => _file_filter |= ParseRight(v, typeof(FileAccessRights)) },
                    { "d=", String.Format("Filter on a specific directory right [{0}]",
                                          String.Join(",", Enum.GetNames(typeof(FileDirectoryAccessRights)))), v => _dir_filter |= ParseRight(v, typeof(FileDirectoryAccessRights)) },
                    { "s=", String.Format("Filter on a standard right [{0}]",
                                          String.Join(",", Enum.GetNames(typeof(StandardAccessRights)))), v => standard_filter |= ParseRight(v, typeof(StandardAccessRights)) },
                    { "x=", "Specify a base path to exclude from recursive search", v => _walked.Add(v.ToLower()) },
                    { "q", "Don't print errors", v => _quiet = v != null },
                    { "onlydirs", "Only check the permissions of directories", v => _only_dirs = v != null },
                    { "h|help", "show this message and exit", v => show_help = v != null },
                };

                List <string> paths = opts.Parse(args);

                if (show_help || (paths.Count == 0))
                {
                    ShowHelp(opts);
                }
                else
                {
                    _type  = ObjectTypeInfo.GetTypeByName("file");
                    _token = NativeBridge.OpenProcessToken(pid);

                    _file_filter |= standard_filter;
                    _dir_filter  |= standard_filter;

                    foreach (string path in paths)
                    {
                        if ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
                        {
                            DumpDirectory(new DirectoryInfo(path));
                        }
                        else
                        {
                            DumpFile(new FileInfo(path));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #8
0
ファイル: LevelObjectFactory.cs プロジェクト: AlFasGD/GDAPI
        /// <summary>Attempts to get the <seealso cref="ObjectTypeInfo"/> for the specified object type.</summary>
        /// <param name="objectType">The object type whose <seealso cref="ObjectTypeInfo"/> to get.</param>
        public static bool TryGetObjectTypeInfo(Type objectType, out ObjectTypeInfo info)
        {
            bool result = objectTypeDictionary.TryGetValue(objectType, out var i);

            info = i as ObjectTypeInfo;
            return(result);
        }
コード例 #9
0
ファイル: ObjectTypesParser.cs プロジェクト: ypawlak/SnmpLabs
        private static IDictionary <OidInfo, ObjectTypeInfo> ParseObjTypesRegexResults(MatchCollection regexResults)
        {
            var parsedObjTypes = new Dictionary <OidInfo, ObjectTypeInfo>();

            foreach (Match match in regexResults)
            {
                string name             = match.Groups[OtNameGrp].Value;
                string parentExpression = match.Groups[OtParentGrp].Value;
                string otSpecification  = match.Groups[OtSpecificationGrp].Value;
                long   sibllingNo       = long.Parse(match.Groups[OtSiblingNoGrp].Value);

                var oid = new OidInfo()
                {
                    Name             = name,
                    SiblingNo        = sibllingNo,
                    ParentExpression = parentExpression
                };

                ObjectTypeInfo parsedType = ParseObjectTypeFromSpecification(otSpecification);

                parsedObjTypes.Add(oid, parsedType);
            }

            return(parsedObjTypes);
        }
コード例 #10
0
ファイル: LevelObjectFactory.cs プロジェクト: AlFasGD/GDAPI
        static LevelObjectFactory()
        {
            // Get object property types from the attributes that are assigned to the enum fields
            var fields = typeof(ObjectProperty).GetFields();
            // default(ObjectParameter) is necessary otherwise an exception will be thrown
            // Reflection really sucks dick when it comes to enums
            var info = fields.Select(i => new KeyValuePair <int, Type>((int)i.GetValue(default(ObjectProperty)), i.GetCustomAttribute <ObjectPropertyTypeAttribute>()?.Type));

            propertyTypeInfo = new Dictionary <int, Type>();
            foreach (var i in info)
            {
                propertyTypeInfo.TryAdd(i.Key, i.Value);
            }
            // I added those 5 lines of code only to realize that I actually do not necessarily need them, hopefully they'll turn out any useful in the near future:tm:
            // For the time being there is no reason to change them at all

            objectTypes          = typeof(GeneralObject).Assembly.GetTypes().Where(t => typeof(GeneralObject).IsAssignableFrom(t)).ToArray();
            objectTypeDictionary = new ObjectTypeInfoDictionary();
            foreach (var t in objectTypes.Select(t => ObjectTypeInfo.GetInfo(t)))
            {
                if (t != null)
                {
                    objectTypeDictionary.Add((IFirstWideDoubleKeyedObject <int?, Type>)t);
                }
            }
        }
コード例 #11
0
ファイル: MibParser.cs プロジェクト: ypawlak/SnmpLabs
        public static ObjectType GetObjectTypeFromInfo(IDictionary <string, IDataType> currentDataTypes,
                                                       ObjectTypeInfo otInfo)
        {
            var objType = new ObjectType()
            {
                Syntax      = otInfo.Syntax,
                Size        = otInfo.SyntaxSize,
                SizeRange   = otInfo.SyntaxSizeRange,
                Access      = otInfo.Access,
                Description = otInfo.Description,
                Status      = otInfo.Status
            };

            if (!string.IsNullOrEmpty(otInfo.Syntax) && currentDataTypes.ContainsKey(otInfo.Syntax))
            {
                objType.DataType = currentDataTypes[otInfo.Syntax];
            }
            else
            {
                Debug.WriteLine(string.Format("Original DataType not found for ObjectType syntax: {0} ",
                                              otInfo.Syntax));
            }

            return(objType);
        }
コード例 #12
0
        private void InitObject(
            LevelObjectView obj,
            ObjectTypeInfo objectTypeInfo,
            ObjectProtoInfo objectProtoInfo,
            SpawnLocation spawnLocation,
            LevelSettings levelSettings)
        {
            obj.transform.rotation =
                Quaternion.Euler(0f, spawnLocation.IsXFlipped ? 180f : 0f, 0f);
            var alternating = obj.GetComponent <AlternatingView>();

            if (alternating != null)
            {
                int materialIndex = UnityEngine.Random.Range(
                    0, objectProtoInfo.AvailableMaterials.Length);
                alternating.Material =
                    objectProtoInfo.AvailableMaterials[materialIndex];
            }

            if (objectTypeInfo.Type == playerObjectType)
            {
                List <int> skillIds = playerStateStorage.Get().SkillIds;

                for (int i = 0; i < skillIds.Count; ++i)
                {
                    Skill        skill       = skillStorage.Get(skillIds[i]);
                    BaseSkill    baseSkill   = skillStorage.GetBase(skill.BaseId);
                    ISkillHelper skillHelper =
                        skillHelperStorage.Get(baseSkill.Type);
                    skillHelper.AddSkill(skill, obj.gameObject);
                }
            }
        }
コード例 #13
0
        private List <SpawnsInfo> GetSpawnsInfos(
            LevelSettings levelSettings,
            EnvTypeInfo envTypeInfo,
            bool spawnPlayer,
            PlayerView player = null)
        {
            Profiler.BeginSample("LevelGenerator.GetSpawnsInfos()");
            LevelObjectType[] objectTypes =
                envTypeInfo.SpawnMap.ObjectTypes;
            Array.Sort(objectTypes, objectTypeComparer);
            spawnsInfosBuffer.Clear();
            int objectTypesCount = objectTypes.Length;

            for (int i = 0; i < objectTypesCount; ++i)
            {
                LevelObjectType objectType     = objectTypes[i];
                ObjectTypeInfo  objectTypeInfo =
                    objectTypeInfoStorage.Get(objectType);
                ObjectLevelSettings objectLevelSettings =
                    levelSettings.GetObjectSettings(objectType);
                int spawnsCount = 0;

                if (objectType == playerObjectType)
                {
                    spawnsCount = spawnPlayer ? 1 : 0;
                    spawnPlayer = false;
                }
                else if (objectLevelSettings != null &&
                         UnityEngine.Random.value <=
                         objectLevelSettings.SpawnChance)
                {
                    LevelObjectView objectProto = objectTypeInfo.ProtoInfo.View;
                    spawnsCount = UnityEngine.Random.Range(
                        objectLevelSettings.MinSpawnsPerArea,
                        objectLevelSettings.MaxSpawnsPerArea + 1);
                    var bonus = objectProto.GetComponent <BonusView>();

                    if (bonus != null)
                    {
                        if (player == null ||
                            !bonusSpawnResolver.IsTimeToSpawn(
                                bonus, player))
                        {
                            spawnsCount = 0;
                        }
                        else
                        {
                            bonusSpawnResolver.ActiveBonusObjects +=
                                spawnsCount;
                        }
                    }
                }

                spawnsInfosBuffer.Add(new SpawnsInfo(objectType, spawnsCount));
            }

            return(spawnsInfosBuffer);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            bool show_help = false;

            int pid = Process.GetCurrentProcess().Id;

            try
            {
                OptionSet opts = new OptionSet()
                {
                    { "r", "Recursive tree directory listing",
                      v => _recursive = v != null },
                    { "sddl", "Print full SDDL security descriptors", v => _print_sddl = v != null },
                    { "p|pid=", "Specify a PID of a process to impersonate when checking", v => pid = int.Parse(v.Trim()) },
                    { "w", "Show only write permissions granted", v => _show_write_only = v != null },
                    { "k=", String.Format("Filter on a specific key right [{0}]",
                                          String.Join(",", Enum.GetNames(typeof(KeyAccessRights)))), v => _key_rights |= ParseRight(v, typeof(KeyAccessRights)) },
                    { "s=", String.Format("Filter on a standard right [{0}]",
                                          String.Join(",", Enum.GetNames(typeof(StandardAccessRights)))), v => _key_rights |= ParseRight(v, typeof(StandardAccessRights)) },
                    { "x=", "Specify a base path to exclude from recursive search", v => _walked.Add(v.ToLower()) },
                    { "h|help", "show this message and exit", v => show_help = v != null },
                };

                List <string> paths = opts.Parse(args);

                if (show_help || (paths.Count == 0))
                {
                    ShowHelp(opts);
                }
                else
                {
                    _type  = ObjectTypeInfo.GetTypeByName("key");
                    _token = NativeBridge.OpenProcessToken(pid);

                    foreach (string path in paths)
                    {
                        RegistryKey key = OpenKey(path);

                        if (key != null)
                        {
                            try
                            {
                                DumpKey(key);
                            }
                            finally
                            {
                                key.Close();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #15
0
        private Vector3 GetSize()
        {
            ObjectTypeInfo objectTypeInfo =
                objectTypeInfoStorage.Get(objectType);

            return(new Vector3(
                       itemsAcrossX * objectTypeInfo.Width,
                       0f,
                       itemsAcrossZ * objectTypeInfo.Depth));
        }
コード例 #16
0
    /// <summary>
    /// Get the transformation to interpret task related object data.
    /// </summary>
    /// <param name="row">Grid row</param>
    /// <returns>Transformation that displays object identified by object type and ID.</returns>
    private object RenderRelatedObject(DataRowView row)
    {
        if (row == null)
        {
            return(String.Empty);
        }

        int    objectId    = ValidationHelper.GetInteger(row.Row["SearchTaskRelatedObjectID"], 0);
        string taskTypeRaw = ValidationHelper.GetString(row.Row["SearchTaskType"], "");

        SearchTaskTypeEnum taskType;
        string             objectType = null;


        // try to get search task type. Type doesn't have a default value.
        try
        {
            taskType = ValidationHelper.GetString(taskTypeRaw, "").ToEnum <SearchTaskTypeEnum>();
        }
        catch (Exception ex)
        {
            EventLogProvider.LogEvent(
                EventType.ERROR,
                "Smart search",
                "LISTSEARCHTASKS",
                "Unknown search task type: " + taskTypeRaw + ". Original exception:" + Environment.NewLine + EventLogProvider.GetExceptionLogMessage(ex)
                );

            return(String.Empty);
        }

        // Object type
        objectType = SearchTaskInfoProvider.GetSearchTaskRelatedObjectType(ValidationHelper.GetString(row.Row["SearchTaskObjectType"], ""), taskType);

        // Object cannot be interpreted
        if (String.IsNullOrEmpty(objectType) || (objectId == 0))
        {
            return(String.Empty);
        }

        // create transformation
        ObjectTransformation transformation = new ObjectTransformation(objectType, objectId);

        transformation.Transformation = String.Format("{{% Object.GetFullObjectName(false, true) %}}");

        ObjectTypeInfo typeInfo = ObjectTypeManager.GetTypeInfo(objectType);

        if (typeInfo != null)
        {
            transformation.NoDataTransformation = LocalizationHelper.GetStringFormat("smartsearch.searchtaskrelatedobjectnotexist", typeInfo.GetNiceObjectTypeName(), objectId);
        }

        return(transformation);
    }
コード例 #17
0
        static string AccessMaskToString(ObjectTypeInfo type, uint granted_access)
        {
            if (type.HasFullPermission(granted_access))
            {
                return("Full Permission");
            }

            Object rights = Enum.ToObject(GetTypeAccessRights(type), granted_access & 0xFFFF);

            StandardAccessRights standard = (StandardAccessRights)(granted_access & 0x1F0000);

            return(String.Join(", ", new string[] { standard.ToString(), rights.ToString() }));
        }
コード例 #18
0
        static string AccessMaskToString(ObjectTypeInfo type, uint granted_access)
        {
            if (type.HasFullPermission(granted_access))
            {
                return "Full Permission";
            }

            Object rights = Enum.ToObject(GetTypeAccessRights(type), granted_access & 0xFFFF);

            StandardAccessRights standard = (StandardAccessRights)(granted_access & 0x1F0000);

            return String.Join(", ", new string[] { standard.ToString(), rights.ToString() });
        }
コード例 #19
0
    /// <summary>
    /// Determines whether the children objects have their own children.
    /// </summary>
    /// <param name="excludedTypes">Excluded child types</param>
    private bool ShowChildrenLevel(ICollection <string> excludedTypes)
    {
        ObjectTypeInfo typeInfo = InfoToClone.TypeInfo;

        if (typeInfo.ChildObjectTypes == null)
        {
            return(false);
        }

        return(typeInfo.ChildObjectTypes
               .Where(type => (excludedTypes == null) || !excludedTypes.Contains(type))
               .Select(type => ModuleManager.GetReadOnlyObject(type).TypeInfo.ChildObjectTypes)
               .Any(childTypes => (childTypes != null) && childTypes.Any()));
    }
コード例 #20
0
        private void ValidateExtraObjectTypes()
        {
            ObjectTypeInfo objectTypeInfo =
                objectTypeInfoStorage.Get(objectType);

            for (int i = 0; i < extraObjectTypes.Length; ++i)
            {
                ObjectTypeInfo extraObjectTypeInfo =
                    objectTypeInfoStorage.Get(extraObjectTypes[i]);
                DebugUtils.Assert(
                    objectTypeInfo.Width == extraObjectTypeInfo.Width);
                DebugUtils.Assert(
                    objectTypeInfo.Depth == extraObjectTypeInfo.Depth);
            }
        }
コード例 #21
0
        /// <summary>
        /// 根据对象类型编号获取Object ID
        /// </summary>
        /// <param name="typeId">对象类型编号</param>
        /// <param name="objectId">对象编号</param>
        /// <returns>对象Object ID</returns>
        public static string GetObjectOID(int typeId, int objectId)
        {
            List <ObjectTypeInfo> keyValues = GetObjectTypes();

            ObjectTypeInfo info = (from ObjectTypeInfo temp in keyValues where temp.ID == typeId select temp).FirstOrDefault();

            if (info == null)
            {
                return("");
            }
            else
            {
                return(info.GenerateOID(objectId));
            }
        }
コード例 #22
0
        static void CheckAccess(string path, byte[] sd, ObjectTypeInfo type)
        {
            try
            {
                if (_type_filter.Count > 0)
                {
                    if (!_type_filter.Contains(type.Name.ToLower()))
                    {
                        return;
                    }
                }

                if (sd.Length > 0)
                {
                    uint granted_access = 0;

                    if (_dir_rights != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, type, (uint)_dir_rights, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // As we can get all the righs for the key get maximum
                        if (_dir_rights != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                        }

                        if (!_show_write_only || type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("<{0}> {1} : {2:X08} {3}", type.Name, path, granted_access, AccessMaskToString(type, granted_access));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #23
0
        static void CheckAccess(string path, byte[] sd, ObjectTypeInfo type)
        {
            try
            {
                if (_type_filter.Count > 0)
                {
                    if (!_type_filter.Contains(type.Name.ToLower()))
                    {
                        return;
                    }
                }

                if (sd.Length > 0)
                {
                    uint granted_access = 0;

                    if (_dir_rights != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, type, (uint)_dir_rights, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // As we can get all the righs for the key get maximum
                        if (_dir_rights != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                        }

                        if (!_show_write_only || type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("<{0}> {1} : {2:X08} {3}", type.Name, path, granted_access, AccessMaskToString(type, granted_access));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #24
0
        private void InitialDynamicFieldMapping()
        {
            var properties = ObjectTypeInfo.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var tempList   = new List <DynamicFieldMapping>();

            foreach (var pi in properties)
            {
                var mapping = DynamicFieldMapping.CreateDynamicFieldMapping(pi, this);
                tempList.Add(mapping);
            }
            if (tempList.Count == 0)
            {
                throw new LightDataException(string.Format(SR.NoMappingField, ObjectType.FullName));
            }
            _fieldList = new ReadOnlyCollection <DynamicFieldMapping>(tempList);
        }
コード例 #25
0
        internal HarshEntityMetadataContentType(HarshEntityMetadataRepository repository, TypeInfo entityTypeInfo)
            : base(repository, entityTypeInfo)
        {
            ContentTypeAttribute = ObjectTypeInfo.GetCustomAttribute <ContentTypeAttribute>();

            if (ContentTypeAttribute == null)
            {
                throw Logger.Fatal.ArgumentFormat(
                          nameof(entityTypeInfo),
                          SR.HarshEntityMetadataContentType_NoContentTypeAttribute,
                          entityTypeInfo.FullName
                          );
            }

            ContentTypeId = new ContentTypeIdBuilder(ObjectTypeInfo).ToString();
        }
コード例 #26
0
        private void InitialDynamicFieldMapping()
        {
            PropertyInfo[]             propertys = ObjectTypeInfo.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            List <DynamicFieldMapping> tmepList  = new List <DynamicFieldMapping>();

            foreach (PropertyInfo pi in propertys)
            {
                DynamicFieldMapping mapping = DynamicFieldMapping.CreateDynmaicFieldMapping(pi, this);
                _fieldMappingDictionary.Add(mapping.IndexName, mapping);
                tmepList.Add(mapping);
            }
            if (tmepList.Count == 0)
            {
                throw new LightDataException(string.Format(SR.NoMappingField, ObjectType.FullName));
            }
            _fieldList = new ReadOnlyCollection <DynamicFieldMapping>(tmepList);
        }
コード例 #27
0
    /// <summary>
    /// Based on the TypeInformation gets and returns object's name
    /// </summary>
    /// <param name="row">A DataRow representign the object</param>
    /// <param name="objectTypeInfo">ObjectType of the object passed</param>
    private string GetName(DataRow row, ObjectTypeInfo objectTypeInfo)
    {
        string columnName = objectTypeInfo.DisplayNameColumn;

        if (String.IsNullOrEmpty(columnName))
        {
            columnName = objectTypeInfo.CodeNameColumn;
        }
        string result = row[columnName].ToString();

        if (String.IsNullOrEmpty(result))
        {
            return(GetString("general.na"));
        }

        return(result);
    }
コード例 #28
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        // Register Javascripts
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "DeleteEditView", ScriptHelper.GetScript(
                                                   "var deleteConfirmation = ''; " +
                                                   "function DeleteConfirm() { return confirm(deleteConfirmation); } " +
                                                   "function EditItem(customtableid, itemId) { " +
                                                   "  document.location.replace('" + ResolveUrl(EditItemPage) + "?" +
                                                   (String.IsNullOrEmpty(mEditItemPageAdditionalParams) ? String.Empty : mEditItemPageAdditionalParams + "&") + "objectid=' + customtableid + '&itemId=' + itemId); } " +
                                                   "function ViewItem(customtableid, itemId) { " +
                                                   "  modalDialog('" + ResolveUrl(ViewItemPage) + "?" +
                                                   (String.IsNullOrEmpty(mViewItemPageAdditionalParams) ? String.Empty : mViewItemPageAdditionalParams + "&") + "customtableid=' + customtableid + '&itemId=' + itemId,'ViewItem',600,600); } "));

        // Buttons' tooltips
        editToolTip   = GetString("general.edit");
        deleteToolTip = GetString("general.delete");
        viewToolTip   = GetString("general.view");
        upToolTip     = GetString("general.up");
        downToolTip   = GetString("general.down");

        // Delete confirmation
        ltlScript.Text = ScriptHelper.GetScript("deleteConfirmation = '" + GetString("customtable.data.DeleteConfirmation") + "';");

        gridData.ObjectType           = CustomTableItemProvider.GetObjectType(CustomTableClassInfo.ClassName);
        gridData.OnLoadColumns       += gridData_OnLoadColumns;
        gridData.OnExternalDataBound += gridData_OnExternalDataBound;
        gridData.OnAction            += gridData_OnAction;

        ti = CustomTableItemProvider.GetTypeInfo(CustomTableClassInfo.ClassName);

        if (HasItemOrderField)
        {
            gridData.OrderBy = "ItemOrder ASC";
        }
        else
        {
            gridData.OrderBy = ti.IDColumn;
        }
    }
コード例 #29
0
ファイル: GeneralObject.cs プロジェクト: Altenhh/GDAPI
        static GeneralObject()
        {
            // Get object property types from the attributes that are assigned to the enum fields
            var fields = typeof(ObjectParameter).GetFields();
            // default(ObjectParameter) is necessary otherwise an exception will be thrown
            // Reflection really sucks dick when it comes to enums
            var info = fields.Select(i => new KeyValuePair <int, Type>((int)i.GetValue(default(ObjectParameter)), i.GetCustomAttribute <ObjectParameterTypeAttribute>()?.Type));

            propertyTypeInfo = new Dictionary <int, Type>();
            foreach (var i in info)
            {
                propertyTypeInfo.TryAdd(i.Key, i.Value);
            }
            // I added those 5 lines of code only to realize that I actually do not necessarily need them, hopefully they'll turn out any useful in the near future:tm:

            objectTypes = typeof(GeneralObject).Assembly.GetTypes().Where(t => typeof(GeneralObject).IsAssignableFrom(t)).ToArray();
            initializableObjectTypes = objectTypes.Select(t => ObjectTypeInfo.GetInfo(t)).ToArray();
        }
コード例 #30
0
        public override void Setup(CollectionSourceBase collectionSource, XafApplication application)
        {
            base.Setup(collectionSource, application);
            AutoLoad = false;
            IObjectSpace objectSpace = collectionSource.ObjectSpace;

            objectSpace.Reloaded += new EventHandler(this.ObjectSpace_Reloaded);
            ITypeInfo objectTypeInfo = collectionSource.ObjectTypeInfo;
            var       customSetting  = ObjectTypeInfo.FindAttribute <CategorySettingAttribute>();

            Setting = customSetting;
            Type memberType = null;

            if (customSetting == null)
            {
                IMemberInfo info2 = objectTypeInfo.FindMember("Category");
                if (info2 == null)
                {
                    throw new InvalidOperationException(string.Format("The {0} type does not declare the public {1} property.", objectTypeInfo.FullName, "Category"));
                }
                memberType = info2.MemberType;
            }
            else
            {
                memberType           = customSetting.CategoryType;
                CategoryPropertyName = Setting.PropertyName;
            }

            this.categoriesListViewId = application.FindListViewId(memberType);
            if (string.IsNullOrEmpty(this.categoriesListViewId))
            {
                throw new InvalidOperationException(string.Format("Cannot find ListView for the Category property type {0} in the Application Model. Make sure the property is of the business object type registered in the application.", memberType.FullName));
            }
            if ((base.Model != null) && (this.categoriesListViewId == base.Model.Id))
            {
                throw new InvalidOperationException(string.Format("The default category ListView ({0}) is the same as the container ListView. To avoid recursion, provide different EditorType settings for it.", this.categoriesListViewId));
            }
            this.categoriesDataSource    = application.CreateCollectionSource(objectSpace, memberType, this.categoriesListViewId);
            this.criteriaPropertyName    = "Category." + objectSpace.GetKeyPropertyName(memberType);
            this.typeDescriptionProvider = new CategorizedListEditorTypeDescriptionProvider(objectTypeInfo.Type);
            this.typeDescriptionProvider.AddProvider();
        }
コード例 #31
0
 /// <summary>
 /// Call AGConnectCloudDB.CreateObjectType to init schema.
 /// </summary>
 public void CreateObjectType()
 {
     try
     {
         var            objectTypeInfoHelper = Java.Lang.Class.ForName("com.company.project.ObjectTypeInfoHelper");
         var            javaMethod           = objectTypeInfoHelper.GetMethod("getObjectTypeInfo");
         ObjectTypeInfo objectTypeInfo       = (ObjectTypeInfo)javaMethod.Invoke(objectTypeInfoHelper);
         mCloudDB.CreateObjectType(objectTypeInfo);
         ShowResultPopup(
             "ObjectType created successfully"
             + "\n" +
             "ObjectTypeVersion: " + objectTypeInfo.ObjectTypeVersion
             + "\n" +
             "FormatVersion:" + objectTypeInfo.FormatVersion
             );
     }
     catch (Exception e)
     {
         ShowResultPopup("CreateObjectType failed: " + e.Message);
     }
 }
コード例 #32
0
        private void InitialRelationField()
        {
            var properties        = ObjectTypeInfo.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var collectionTmpList = new List <CollectionRelationFieldMapping>();
            var singleTmpList     = new List <SingleRelationFieldMapping>();

            foreach (var pi in properties)
            {
                var config = MapperConfigManager.LoadRelationDataFieldConfig(ObjectType, pi);
                if (config != null && config.RelationKeyCount > 0)
                {
                    var type     = pi.PropertyType;
                    var typeInfo = type.GetTypeInfo();
                    if (typeInfo.IsGenericType)
                    {
                        var frameType = type.GetGenericTypeDefinition();
                        if (frameType == LCollectionFrameType ||
                            frameType.FullName == "System.Collections.Generic.ICollection`1")
                        {
                            var arguments = typeInfo.GetGenericArguments();
                            type = arguments[0];
                            var handler  = new PropertyHandler(pi);
                            var keyPairs = config.GetRelationKeys();
                            var mapping  = new CollectionRelationFieldMapping(pi.Name, this, type, keyPairs, handler);
                            collectionTmpList.Add(mapping);
                        }
                    }
                    else
                    {
                        var handler  = new PropertyHandler(pi);
                        var keyPairs = config.GetRelationKeys();
                        var mapping  = new SingleRelationFieldMapping(pi.Name, this, type, keyPairs, handler);
                        singleTmpList.Add(mapping);
                    }
                }
            }

            _collectionRelationFields = new ReadOnlyCollection <CollectionRelationFieldMapping>(collectionTmpList);
            _singleRelationFields     = new ReadOnlyCollection <SingleRelationFieldMapping>(singleTmpList);
        }
コード例 #33
0
 static Type GetTypeAccessRights(ObjectTypeInfo type)
 {
     switch (type.Name.ToLower())
     {
         case "directory":
             return typeof(DirectoryAccessRights);
         case "event":
             return typeof(EventAccessRights);
         case "section":
             return typeof(SectionAccessRights);
         case "mutant":
             return typeof(MutantAccessRights);
         case "semaphore":
             return typeof(SemaphoreAccessRights);
         case "job":
             return typeof(JobObjectAccessRights);
         case "symboliclink":
             return typeof(SymbolicLinkAccessRights);
         default:
             throw new ArgumentException("Can't get type for access rights");
     }
 }
    /// <summary>
    /// Based on the TypeInformation gets and returns object's name
    /// </summary>
    /// <param name="row">A DataRow representign the object</param>
    /// <param name="objectTypeInfo">ObjectType of the object passed</param>
    private string GetName(DataRow row, ObjectTypeInfo objectTypeInfo)
    {
        string columnName = objectTypeInfo.DisplayNameColumn;
        if (String.IsNullOrEmpty(columnName))
        {
            columnName = objectTypeInfo.CodeNameColumn;
        }
        string result = row[columnName].ToString();
        if (String.IsNullOrEmpty(result))
        {
            return GetString("general.na");
        }

        return result;
    }
コード例 #35
0
        static void Main(string[] args)
        {
            bool show_help = false;

            int pid = Process.GetCurrentProcess().Id;

            try
            {
                OptionSet opts = new OptionSet() {
                        { "r", "Recursive tree directory listing",  
                            v => _recursive = v != null },                                  
                        { "sddl", "Print full SDDL security descriptors", v => _print_sddl = v != null },
                        { "p|pid=", "Specify a PID of a process to impersonate when checking", v => pid = int.Parse(v.Trim()) },
                        { "w", "Show only write permissions granted", v => _show_write_only = v != null },
                        { "k=", String.Format("Filter on a specific key right [{0}]", 
                            String.Join(",", Enum.GetNames(typeof(KeyAccessRights)))), v => _key_rights |= ParseRight(v, typeof(KeyAccessRights)) },  
                        { "s=", String.Format("Filter on a standard right [{0}]", 
                            String.Join(",", Enum.GetNames(typeof(StandardAccessRights)))), v => _key_rights |= ParseRight(v, typeof(StandardAccessRights)) },  
                        { "x=", "Specify a base path to exclude from recursive search", v => _walked.Add(v.ToLower()) },
                        { "h|help",  "show this message and exit", v => show_help = v != null },
                    };

                List<string> paths = opts.Parse(args);

                if (show_help || (paths.Count == 0))
                {
                    ShowHelp(opts);
                }
                else
                {
                    _type = ObjectTypeInfo.GetTypeByName("key");
                    _token = NativeBridge.OpenProcessToken(pid);

                    foreach (string path in paths)
                    {
                        RegistryKey key = OpenKey(path);

                        if (key != null)
                        {
                            try
                            {
                                DumpKey(key);
                            }
                            finally
                            {
                                key.Close();
                            }
                        }
                    }
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #36
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (InfoToClone != null)
        {
            ScriptHelper.RegisterJQuery(this.Page);

            typeInfo = InfoToClone.TypeInfo;

            siteElem.AllowGlobal = typeInfo.SupportsGlobalObjects;

            SetLabel(lblDisplayName, "displaynamelabel", "clonning.newdisplayname");
            SetLabel(lblCodeName, "codenamelabel", "clonning.newcodename");

            lblKeepFieldsTranslated.ToolTip = GetString("clonning.settings.keepfieldstranslated.tooltip");
            lblCloneUnderSite.ToolTip = GetString("clonning.settings.cloneundersite.tooltip");
            lblMetafiles.ToolTip = GetString("clonning.settings.metafiles.tooltip");
            lblMaxRelativeLevel.ToolTip = GetString("clonning.settings.maxrelativelevel.tooltip");

            plcCodeName.Visible = (typeInfo.CodeNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN);
            plcDisplayName.Visible = (typeInfo.DisplayNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN) && !typeInfo.DisplayNameColumn.EqualsCSafe(typeInfo.CodeNameColumn, true);

            // Try to load Custom properties
            customProperties = LoadCustomProperties(typeInfo.ObjectType);
            if ((customProperties == null) && (typeInfo.ObjectType != typeInfo.OriginalObjectType))
            {
                // Try get original object type settings control
                customProperties = LoadCustomProperties(typeInfo.OriginalObjectType);
            }

            if (customProperties != null)
            {
                headCustom.Text = GetCustomParametersTitle();
                customProperties.ID = "customProperties";
                customProperties.InfoToClone = InfoToClone;

                plcCustomParameters.Controls.Add(customProperties);
                plcCustomParametersBox.Visible = customProperties.DisplayControl;

                if (customProperties.HideDisplayName)
                {
                    plcDisplayName.Visible = false;
                }
                if (customProperties.HideCodeName)
                {
                    plcCodeName.Visible = false;
                }

                if (!RequestHelper.IsPostBack())
                {
                    TransferExcludedTypes();
                }
            }

            // Show site DDL only for Global Admin and for controls which have SiteID (and are not under group or any other parent) and are not from E-Commerce/Forums module
            int sitesCount = SiteInfoProvider.GetSitesCount();
            plcCloneUnderSite.Visible = typeInfo.SupportsCloneToOtherSite
                && (typeInfo.SiteIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN)
                && (MembershipContext.AuthenticatedUser != null)
                && (MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
                && ((typeInfo.SupportsGlobalObjects && (sitesCount > 0)) || (sitesCount > 1))
                && (InfoToClone.Generalized.ObjectGroupID == 0)
                && (InfoToClone.Generalized.ObjectParentID == 0)
                && !typeInfo.ModuleName.EqualsCSafe(ModuleName.ECOMMERCE, true)
                && !typeInfo.ModuleName.EqualsCSafe(ModuleName.FORUMS, true)
                && (typeInfo.OriginalObjectType != CategoryInfo.OBJECT_TYPE);

            if (((typeInfo.BindingObjectTypes != null) && (typeInfo.BindingObjectTypes.Count > 0)) || ((typeInfo.OtherBindingObjectTypes != null) && (typeInfo.OtherBindingObjectTypes.Count > 0)))
            {
                // Remove site binding from bindings if exists
                List<string> bindings = new List<string>();
                if (typeInfo.BindingObjectTypes != null)
                {
                    bindings.AddRange(typeInfo.BindingObjectTypes);
                }
                if (typeInfo.OtherBindingObjectTypes != null)
                {
                    bindings.AddRange(typeInfo.OtherBindingObjectTypes);
                }
                if (!string.IsNullOrEmpty(typeInfo.SiteBinding))
                {
                    if (bindings.Contains(typeInfo.SiteBinding))
                    {
                        bindings.Remove(typeInfo.SiteBinding);
                    }
                }
                if (bindings.Count > 0)
                {
                    List<string> excludedTypes = new List<string>();
                    excludedTypes.AddRange(excludedBindings);
                    excludedTypes.AddRange(excludedOtherBindings);

                    int itemNumber = 0;
                    lblBindings.ToolTip = GetCloneHelpText(bindings, excludedTypes, out itemNumber);

                    if (itemNumber == 1)
                    {
                        lblBindings.Text = lblBindings.ToolTip;
                        lblBindings.ToolTip = "";
                    }
                    else
                    {
                        SetLabel(lblBindings, "bindingslabel", "clonning.settings.bindings");
                    }

                    plcBindings.Visible = itemNumber > 0;
                }
            }

            if ((typeInfo.ChildObjectTypes != null) && (typeInfo.ChildObjectTypes.Count > 0))
            {
                int itemNumber = 0;
                lblChildren.ToolTip = GetCloneHelpText(typeInfo.ChildObjectTypes, excludedChildren, out itemNumber);

                if (itemNumber == 1)
                {
                    lblChildren.Text = lblChildren.ToolTip;
                    lblChildren.ToolTip = "";
                }
                else
                {
                    lblChildren.Text = GetString("clonning.settings.children");
                }

                plcChildren.Visible = itemNumber > 0;
                plcChildrenLevel.Visible = ShowChildrenLevel(excludedChildren);
            }

            if (!string.IsNullOrEmpty(typeInfo.SiteBinding) && (InfoToClone.Generalized.ObjectGroupID == 0))
            {
                // For objects with SiteID column allow site bindings only for global versions of the object (for example polls)
                if ((typeInfo.SiteIDColumn == ObjectTypeInfo.COLUMN_NAME_UNKNOWN) || (InfoToClone.Generalized.ObjectSiteID == 0))
                {
                    lblAssignToCurrentSite.ToolTip = GetString("clonning.settings.assigntocurrentsite.tooltip");
                    plcAssignToCurrentSite.Visible = true;

                    lblSiteBindings.ToolTip = GetCloneHelpText(new List<string>() { typeInfo.SiteBinding });

                    plcSiteBindings.Visible = true;
                }
            }

            if ((InfoToClone.MetaFiles != null) && (InfoToClone.MetaFiles.Count > 0))
            {
                plcMetafiles.Visible = true;
            }

            // Preselect site of the object as a "clone under site" option
            if (plcCloneUnderSite.Visible && !RequestHelper.IsPostBack())
            {
                siteElem.SiteName = InfoToClone.Generalized.ObjectSiteName;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (plcCodeName.Visible)
                {
                    txtCodeName.Text = InfoToClone.Generalized.GetUniqueCodeName();
                }
                if (plcDisplayName.Visible)
                {
                    txtDisplayName.Text = InfoToClone.Generalized.GetUniqueDisplayName();
                }

                // Exception for cultures for assigning to current site (for cultures the default value should be false)
                if (typeInfo.ObjectType == CultureInfo.OBJECT_TYPE)
                {
                    chkAssignToCurrentSite.Checked = false;
                }
            }

            if (plcChildren.Visible)
            {
                LoadMaxRelativeLevel();
            }
        }
    }
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        // Register Javascripts
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "DeleteEditView", ScriptHelper.GetScript(
            "var deleteConfirmation = ''; " +
            "function DeleteConfirm() { return confirm(deleteConfirmation); } " +
            "function EditItem(customtableid, itemId) { " +
            "  document.location.replace('" + ResolveUrl(EditItemPage) + "?" +
            (String.IsNullOrEmpty(mEditItemPageAdditionalParams) ? String.Empty : mEditItemPageAdditionalParams + "&") + "objectid=' + customtableid + '&itemId=' + itemId); } " +
            "function ViewItem(customtableid, itemId) { " +
            "  modalDialog('" + ResolveUrl(ViewItemPage) + "?" +
            (String.IsNullOrEmpty(mViewItemPageAdditionalParams) ? String.Empty : mViewItemPageAdditionalParams + "&") + "customtableid=' + customtableid + '&itemId=' + itemId,'ViewItem',600,600); } "));

        // Buttons' tooltips
        editToolTip = GetString("general.edit");
        deleteToolTip = GetString("general.delete");
        viewToolTip = GetString("general.view");
        upToolTip = GetString("general.up");
        downToolTip = GetString("general.down");

        // Delete confirmation
        ltlScript.Text = ScriptHelper.GetScript("deleteConfirmation = '" + GetString("customtable.data.DeleteConfirmation") + "';");

        gridData.ObjectType = CustomTableItemProvider.GetObjectType(CustomTableClassInfo.ClassName);
        gridData.OnLoadColumns += gridData_OnLoadColumns;
        gridData.OnExternalDataBound += gridData_OnExternalDataBound;
        gridData.OnAction += gridData_OnAction;

        ti = CustomTableItemProvider.GetTypeInfo(CustomTableClassInfo.ClassName);

        if (HasItemOrderField)
        {
            gridData.OrderBy = "ItemOrder ASC";
        }
        else
        {
            gridData.OrderBy = ti.IDColumn;
        }
    }
コード例 #38
0
    private string GetTargetObjectType(ObjectTypeInfo bindingTypeInfo)
    {
        // Search for parent in TYPEINFO
        var parent = bindingTypeInfo.ParentObjectType;
        if (!String.IsNullOrEmpty(parent) && (parent != ObjectType))
        {
            // If parent is different from control's object type use it.
            return parent;
        }

        // Otherwise search in site object
        var siteObject = bindingTypeInfo.SiteIDColumn;
        if (!String.IsNullOrEmpty(siteObject) && (siteObject != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
        {
            return SiteInfo.OBJECT_TYPE;
        }

        // If site object not specified use bindings. Find first binding dependency and use it's object type
        var dependency = bindingTypeInfo.ObjectDependencies.FirstOrDefault(x => x.DependencyType == ObjectDependencyEnum.Binding);
        if (dependency != null)
        {
            return dependency.DependencyObjectType;
        }

        return null;
    }
コード例 #39
0
        static void Main(string[] args)
        {
            bool show_help = false;
            uint standard_filter = 0;

            int pid = Process.GetCurrentProcess().Id;

            try
            {
                OptionSet opts = new OptionSet() {
                            { "r", "Recursive tree directory listing",  
                                v => _recursive = v != null },                                  
                            { "sddl", "Print full SDDL security descriptors", v => _print_sddl = v != null },
                            { "p|pid=", "Specify a PID of a process to impersonate when checking", v => pid = int.Parse(v.Trim()) },
                            { "w", "Show only write permissions granted", v => _show_write_only = v != null },
                            { "f=", String.Format("Filter on a specific file right [{0}]", 
                                String.Join(",", Enum.GetNames(typeof(FileAccessRights)))), v => _file_filter |= ParseRight(v, typeof(FileAccessRights)) },  
                            { "d=", String.Format("Filter on a specific directory right [{0}]", 
                                String.Join(",", Enum.GetNames(typeof(FileDirectoryAccessRights)))), v => _dir_filter |= ParseRight(v, typeof(FileDirectoryAccessRights)) },  
                            { "s=", String.Format("Filter on a standard right [{0}]", 
                                String.Join(",", Enum.GetNames(typeof(StandardAccessRights)))), v => standard_filter |= ParseRight(v, typeof(StandardAccessRights)) },  
                            { "x=", "Specify a base path to exclude from recursive search", v => _walked.Add(v.ToLower()) },
                            { "q", "Don't print errors", v => _quiet = v != null },
                            { "onlydirs", "Only check the permissions of directories", v => _only_dirs = v != null },
                            { "h|help",  "show this message and exit", v => show_help = v != null },
                        };

                List<string> paths = opts.Parse(args);

                if (show_help || (paths.Count == 0))
                {
                    ShowHelp(opts);
                }
                else
                {
                        _type = ObjectTypeInfo.GetTypeByName("file");
                        _token = NativeBridge.OpenProcessToken(pid);

                        _file_filter |= standard_filter;
                        _dir_filter |= standard_filter;

                        foreach (string path in paths)
                        {
                            if ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
                            {
                                DumpDirectory(new DirectoryInfo(path));
                            }
                            else
                            {
                                DumpFile(new FileInfo(path));
                            }
                        }
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }