コード例 #1
0
        public void CreateDriver(DependencyObject root)
        {
            //FormとUserControlを全取得
            var recursiveCheck = new List <DependencyObject>();
            var targets        = new Dictionary <Type, DependencyObject>();

            //ルートはUserControlでなくても指定されたらUserControlDriverを作れるようにする
            if (!(root is UserControl))
            {
                targets[root.GetType()] = root;
            }

            var getFromControlTreeOnly = new List <Type>();

            GetAllWindowAndUserControl(false, root, targets, getFromControlTreeOnly, recursiveCheck);

            //ドライバ情報を取得
            var driverInfos = new Dictionary <Type, DriverInfo <DependencyObject> >();

            foreach (var e in targets)
            {
                var fileName = $"{_driverTypeNameManager.MakeDriverType(e.Value)}.cs";
                var info     = CreateDriverInfo(e.Value, fileName);
                driverInfos[e.Key] = info;
            }

            //変換
            foreach (var e in driverInfos)
            {
                var driverName = _driverTypeNameManager.MakeDriverType(e.Value.Target, out var nameSpace);
                if (string.IsNullOrEmpty(nameSpace))
                {
                    nameSpace = DriverCreatorAdapter.SelectedNamespace;
                }

                //コード生成
                DriverCreatorAdapter.AddCode($"{driverName}.cs", GenerateCode(root, e.Value.Target, nameSpace, driverName, e.Value.Usings, e.Value.Members, getFromControlTreeOnly), e.Value.Target);
            }
        }
コード例 #2
0
        public string CreateDriverClassName(object coreObj)
        {
            var driverTypeNameManager = new DriverTypeNameManager(DriverCreatorAdapter.SelectedNamespace, DriverCreatorAdapter.TypeFullNameAndWindowDriver, DriverCreatorAdapter.TypeFullNameAndUserControlDriver);

            return(driverTypeNameManager.MakeDriverType(coreObj, out var _));
        }